How to mount a host directory in a Docker container

后端 未结 25 1606
庸人自扰
庸人自扰 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:01

    Had the same problem. Found this in the docker documentation:

    Note: The host directory is, by its nature, host-dependent. For this reason, you can’t mount a host directory from Dockerfile, the VOLUME instruction does not support passing a host-dir, because built images should be portable. A host directory wouldn’t be available on all potential hosts.

    So, mounting a read/write host directory is only possible with the -v parameter in the docker run command, as the other answers point out correctly.

提交回复
热议问题