Single file volume mounted as directory in Docker

前端 未结 6 1780
春和景丽
春和景丽 2020-12-23 19:00

Docker documentation says that it\'s possible to mount a single file into a Docker container:

The -v flag can also be used to mount a single file - in

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-23 19:21

    When running docker inside docker (by mounting /var/run/docker.sock for example), you need to be aware that if you do mounts inside docker, the filepaths that are used are always the one on your host.

    So if on your host you do the following mount :

    -v /tmp/foobar.txt:/my/path/foobar.txt
    

    you should not do the following mount inside docker :

    -v /my/path/foobar.txt:/my/other/path.txt
    

    but instead, use the host filepath, eg :

    -v /tmp/foobar.txt:/my/other/path.txt
    

提交回复
热议问题