How to mount a host directory in a Docker container

后端 未结 25 1572
庸人自扰
庸人自扰 2020-11-22 12:43

I am trying to mount a host directory into a Docker container so that any updates done on the host is reflected into the Docker containers.

Where am I doing somethin

25条回答
  •  青春惊慌失措
    2020-11-22 13:00

    For Windows 10 users, it is important to have the mount point inside the C:/Users/ directory. I tried for hours to get this to work. This post helped but it was not obvious at first as the solution for Windows 10 is a comment to an accepted answer. This is how I did it:

    docker run -it -p 12001:80 -v //c/Users/C/Desktop/dockerStorage:/root/sketches \
     /bin/bash
    

    Then to test it, you can do echo TEST > hostTest.txt inside your image. You should be able to see this new file in the local host folder at C:/Users/C/Desktop/dockerStorage/.

提交回复
热议问题