9

We are trying to create a docker image from a container based on the Oracle 12c Enterprise Edition image from docker store (https://store.docker.com/images/oracle-database-enterprise-edition). We have the container working ok and then, after stopping the container we create an image based on that container with the following command.

docker commit Oracle_12 oracle/oradb:1

Then, we try to run a container using the commited image with the following command:

docker run -d -it --name oradb_cont -p 1512:1521 -p 5500:5500 oracle/oradb:1

This container fails with the following error:

Start up Oracle Database
Wed Nov 15 10:31:29 UTC 2017
start database
start listener
The database is ready for use .
tail: cannot open '/u01/app/oracle/diag/rdbms/orclcdb/ORCLCDB/trace/alert_ORCLCDB.log' for reading: No such file or directory
tail: no files remaining

The container is "Exited" although the message "The database is ready for use". We have attached a bash to the container to inspect where the missing file is. And the result seems to be that the "/diag" folder is a broken symlink:

enter image description here

Starting the original Oracle 12c container and attaching a bash, the folder is present. It seems symlink is broken or the file is not present only in the image created from the container.

Community
  • 1
  • 1
Fernando M
  • 397
  • 5
  • 9

1 Answers1

3

The problem is that /ORCL is a data volume. The commit operation does not include any files that are inside volumes. You can check the commit documentation for more info.

Thus when starting the new instance, it appears that somehow the log file is being referenced and has not been yet created. Your current container is in an inconsistent state, as the files under '/ORCL' that were present in the commited container are missing from the new instance.

If you are running the new instance on a new machine you need to migrate the old volume into the new machine. You can find the volume of the old container by running docker inspect -f '{{ .Mounts }}' <old-container-name>, and migrate as specified in How to port data-only volumes from one host to another?

If you are running the new instance on the same machine, just mount the old volume using: <volume-name-or-id>:/ORCL

In general, as a best practice, you shouldn't rely on the commit command to get identical instances of a container. Rather build a DockerFile which extends the base image, and then add customizations by selecting only the necessary files to copy over on the new instance.

yamenk
  • 46,736
  • 10
  • 93
  • 87
  • In my case I hit this issue for a silly reason. Initially I had been using MySql and then switched to Oracle. I literally swapped the image name in my docker-compose.yml. So I was trying to make use of a volume that was previously used and I hadn't renamed the container. I had to delete the `db` volume because it was set up initially for mysql. Once it was recreated for the oracle DB, all was well. – wgwz Aug 21 '20 at 14:55
  • 1
    And just a heads up, the `/ORCL` volume is removed from the Dockerfiles on Oracle's Github repo (which are different from the prebuilt images on Docker Hub or Oracle Container Registry.) This will require building the image yourself, and they provide a script that makes it pretty easy. See this resolved issue for more detail on the volume removal: https://github.com/oracle/docker-images/issues/640 – David Birks Sep 02 '20 at 12:48