Docker: Can I mount a folder within a volume to a container?

So you mount a volume to a container like so: -v volume:/path/to/target-directory.

I want to do: -v volume/source-directory:/path/to/target-directory. Rather than creating more volumes, I’d rather have one with directories in it that I mount to various places on the container file system.

Is this possible? Google shows no examples AFAICT.

both source and destination can be full paths.

some examples:

 -v /etc/localtime:/etc/localtime #mounts a single file in the container
 -v volume_example:/mnt/media #creates a new volume
 -v /srv/media/tv:/tv #mounts an existing directory

1 Like

Thanks, but I meant mounting a folder within a volume. So for example:

docker volume create test-volume
mkdir /path/to/test-volume/on/host/new-directory
docker run -dit --name application -v test-volume/new-directory:/path/to/mount/point

I found this:

Maybe one day.

Yeah, sorry.

If you’re running btrfs, you could always create a subvol somewhere else with your desired config.

1 Like

A volume is a term that docker uses to designate something like basically a writable image.

You could use symlinks within a container (that’s a bit meh and ugly, depending on what you’re running it could help).

1 Like

The only quick way I would know of doing anything of that nature would be to bind-mount within the given volume.

Perhaps here…

…And here might be of assistance.

P.s.-Sackoverflow had a few usefull answers as well.