Docker - cannot mount volume over existing file, file exists

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Docker - cannot mount volume over existing file, file exists



I'm trying to build a data container for my application in Docker. I run this command to expose some volumes:


docker run --name svenv.nl-data -v /etc/environment -v /etc/ssl/certs -v /var/lib/mysql -d svenv/svenv.nl-data



The problem is that i get this error from this command:


Error response from daemon: cannot mount volume over existing file, file exists /var/lib/docker/aufs/mnt/aefa66cf55357e2e1e4f84c2d4d2d03fa2375c8900fe3c0e1e6bc02f13e54d05/etc/environment



If I understand the Docker documentation correctly. Creating volumes for single files is supported. So I don't understand why I get this error.



Is there somebody who can explain this to me? I'm running Docker 1.9.1 on Ubuntu 14.04.





have you solved it in some way ?
– Robert
Apr 13 '16 at 1:32





Turned out some file cannot be overwritten by docker irrc. It think /etc/environment is reserved.
– Sven van de Scheur
Jun 22 '16 at 15:55




3 Answers
3



You should use:


-v /etc/environment:/etc/environment



instead of:


-v /etc/environment



The former maps container volume to the host volume.
The latter tries to create a new volume at /etc/environment and fails since this directory already exists.


/etc/environment



I guess because you are not mounting a file but instead declaring a mount. Try this notation instead: -v <full path to a file you want to overwrite the target with>:/etc/environment


-v <full path to a file you want to overwrite the target with>:/etc/environment





I don't want to overwrite the file with an other file. What i'm trying to achieve is to mark the /etc/environment as volume so it can be used by another container using --volumes-from. Is this even possible?
– Sven van de Scheur
Nov 25 '15 at 22:12



Suppose you are under Linux, run the following code


docker run -it --rm -v /local_dir:/image_root_dir/mount_dir image_name



Here is some detail:


-it: interactive terminal
--rm: remove container after exit the container
-v: volume or say mount your local directory to a volume



Since the mount function will 'cover' the directory in your image, your should always make a new directory under your images root directory.



Visit official documentation Use bind mounts to get more information.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

RpkgpxVEfN2X7j
AA 9KzB8KIJe6mCpBx5hndIxVcCrpU,eUWMlmkPFAWwnN,UMWuwYpY6 OPkf,xlDTpvKUtwxQrRU7

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham