我可以在docker run命令中挂载卷的子目录吗
问题描述:
在尝试使用docker时,我试图避免缓慢的 osxfs
。因此,我正在运行docker-sync卷容器。
I'm trying to avoid slow osxfs
when using docker. So I'm running docker-sync volume container.
我只想将此卷的子目录安装到另一个容器中。
I want to mount only subdir of this volume to another container.
当前示例错误出:
docker: Error response from daemon: create docker-sync/www/marcopolo.front: "docker-sync/www/marcopolo.front" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed.
See 'docker run --help'.
答
如您所见,docker当前不提供一种从命名卷内部仅装载子目录的方法。您必须先装载到整个卷,然后选择特定的文件,或者可以在单独的位置装载到卷,并在图像中包括指向特定子目录的符号链接。
As you've seen, docker does not currently provide a way to mount only a sub directory from inside of a named volume. You'll have to mount to entire volume and then either pick your specific files, or you can mount to volume in a separate location and include a symbolic link to your specific subdirectory as part of the image.