2

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 !

1
  • 1
    config files removed? Data volumes are designed to share files between host and container. If the shared directory is empty on the host it would be empty in the container. See: docs.docker.com/userguide/dockervolumes Commented Aug 4, 2014 at 7:49

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.