Volume mount to directory containing files in the image

I wanted to make the nginx.conf file in Nginx available to be edited outside of the container. So after creating a container without a volume mount and checking that in the container default.conf definitely lives in /etc/nginx I then created a directory on the coast and in the container run command I set a -v <host-directory:/etc/nginx and then fired up a new container.

However the container failed to run immediately as I guess that host directory which contains nothing became the /etc/nginx directory and all the files that would gave been there are gone.

How do you handle situations like this? I thought of creating the first docker container without the volume – copy off the contents of /etc/nginx to the host, then create a new container with the -v and making sure that I copied all those files into the directory I was going to -v to /etc/nginx

submitted by /u/CeramicVulture
[link] [comments]
Source: Reddit