Preserving the Oracle Database Container

In our last post, we added DBMS_CLOUD to our Oracle 23ai Container. Since that change was done via adding database objects, the version of our container is now different than what we had downloaded. Additionally, we’ve upgraded the database objects for APEX a couple of posts back, adding more delta from the container we downloaded.

Thus, if we wanted to quickly spin up a new, fresh database that looks like the one we have, we’d be out of luck. While upgrading APEX & adding DBMS_CLOUD only take minutes, it could get repetitive if we need to do this regularly. And that’s just all that’s different today - things will change as we add more features & applications over time.

To solve this issue, we can create a new image from our container. That image can then be used to create new containers - just like we’ve used the images provided by Oracle.

To wrap up this series, let’s walk through how we can create an image based on our container so that we can spin up new containers that have DBMS_CLOUD, APEX and anything else we want pre-installed.

Creating a New Image

We’ll start by creating a new image.

  1. From Podman Desktop, locate and stop the oracle container.

It is important to stop the container before committing it, otherwise you risk saving a corrupt container.

  1. Open a new terminal window and enter and run the following command:
podman commit oracle

This will take a few minutes to complete. You should see something similar to the screenshot below as this is running:

Next, let’s get a list of all images on our local repository.

  1. Enter and run the following command:
podman images

You should see something similar to the screenshot below:

  1. Take note of the IMAGE ID of the REPOSITORY named <none>.

  2. Run the following command, replacing [IMAGE ID] with the IMAGE ID from the previous step.

podman tag [IMAGE ID] oracle-new
  1. Switch back to Podman Desktop and select the Images tab. Notice that there should be a new entry called localhost/oracle-new. This is the image that was just created and tagged.

  1. Create a new container from the new image by clicking on the Play button.

  2. Optionally enter a Container Name and click Start Container and you should be up and running right where you left off!

Ideally, you would destroy your original Oracle Database container first and then use the command line to create a new one based off of the new image. You can do that by running this code:

podman run --name oracle --ip 10.88.0.2 -p 1521:1521 localhost/oracle-new

Summary

Creating a new image based on a changed container is a helpful way to preserve your work, should you need to start over from a specific place. Keep in mind that if a new Oracle 23ai image was posted by Oracle, you would need to pull that down and re-apply all of the infrastructure changes there. Thus, it’s a good idea to try to keep any of these changes scripted so that they can be applied quickly and in a single script.

This post will likely wrap up the series Containerized, Local Oracle 23ai Environment - at least for now. I’m sure that I’ll find additional things that I want to add to my local development environment, and when I do, I’ll be sure to add them to this series.

If you haven’t already, be sure to start at the first post and go through all of them. I’ve tried to be as specific as possible and provided detailed steps, code snippets and screen shots. Having said that, there’s likely issues and/or typos that make things less than perfect. Please let me know if you find one of those, as I can quickly correct it if and when necessary.

References


Photo by Samsung Memory on Unsplash

2
Subscribe to my newsletter

Read articles from Scott Spendolini directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Scott Spendolini
Scott Spendolini

"Bumpy roads lead to beautiful places" Senior Director @ Oracle 🧑‍💻 #orclapex fan since '99 🛠️ https://spendolini.blog 💻 Oracle Ace Alumni ♠️ Bleed Syracuse Orange 🍊 Golf when I can ⛳️ Austin, TX 🎸🍻 Views are my own 🫢