Docker - cannot mount volume over existing file, file exists

后端 未结 3 1181
感动是毒
感动是毒 2021-02-07 08:30

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/environmen         


        
3条回答
  •  萌比男神i
    2021-02-07 09:10

    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.

提交回复
热议问题