I would like to know the best way to build and run a container based on the ibmcom/db2 image, using a db restore from my existing db. I have been successfully running a docker container based on the now gone express-c base image.Using the old image I could copy my db restore files and restore them inside the container as part of my build process.Since the express-c base image is no longer available, I have been trying to get to the same level of functionality using the currently available developer-c base image from docker hubTrying to reuse my Dockerfile did not work as it now appears that DB2 takes ages to start and initialize. Therefore by the time I try to restore my own DBs on it, the db2inst user is not initialized. I have followed the Build Your Own section with no success:
You can use the Db2 container as a base to build your own custom container. Customizations may include additional setup scripts to execute after Db2 setup has completed, different license activation keys, additional OS packages installed, etc.
To build your own, create a new Dockerfile and specify the desired Db2 base in the FROM line in the Dockerfile. The following example builds a simple container with Db2 as a base and copy a custom script into the /var/customdirectory. Any script copied into the /var/custom will be automatically executed after main Db2 setup has completed.
RUN mkdir /var/custom
COPY createschema.sh /var/customRUN chmod a+x /var/custom/createschema.sh
The custom script is copied to the container. When run the container it tries to execute it but runs into permission issues. I am working through those now but I am not sure I am going the right way about this. I still have to wait for the container to go through all the db2 initialization after running it. This used to be instantaneous on the express-c container. Ideally I would like to see a working example, as the documentation on this is a bit flaky.
Alternatively a bit more on how can I migrate my old container, based on the express-c image, to the new developer-c image.
FROM ibmcom/db2RUN mkdir /var/customCOPY createschema.sh /var/customRUN chmod a+x /var/custom/createschema.sh