can I mount subdir of volume in docker run command

2020-05-03 11:32发布

问题:

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.

Current example errors out:

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'.

回答1:

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.