Reputation: 129
I already installed Docker on Ubuntu successful. So, next step, I will install a new program on this container. The requirement is bind a config folder that contain some essential config files from the container to the host. I tried to use the command to map the shared directory between container and host in Docker tutorial. The command is:
docker run -d -P -v /path/to/shared_directory_host/:/path/to/shared_directory_container/ ubuntu:12.04
But all config files in the config folder on my container is removed because of the empty shared directory in my host. So, all that I want is bind all config files to shared directory on host at the beginning. Then, when I copy the image into another computer, I just type the above simple command and then I might be able to config the program.
Anyone can help me to get out with this problem ! Thank you !
Upvotes: 2
Views: 1250
Reputation: 996
So the problem is you are mounting a directory over your container conf dir.
You could mount the host dir in the container then have a script that runs in the container and copy your configs into the mounted container (or symlink them if you want to make changes that are reflected in the container.
So if you do something like this in your Dockerfile
ADD config_script.sh /opt/config_script.sh
RUN chmod +x /opt/config_script.sh
CMD['/opt/config_script.sh']
make sure your config script runs in the foreground and starts your final process, then before you start your process synlink the config files into the mounted dir, then that might do what you want.
Upvotes: 2