Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Oracle12c Enterprise image created from container symlink broken

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.

like image 601
Fernando M Avatar asked Nov 15 '17 10:11

Fernando M


1 Answers

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.

like image 174
yamenk Avatar answered Oct 22 '22 00:10

yamenk