I have a named volume called foo
. I can find its physical location on the host via docker volume inspect foo
which gives me something like /var/lib/docker/volumes/foo/_data
. I want to be able to rsync files from and to that directory on the host (i.e from and to that named volume) but I want to avoid doing that directly on that path which will also require me using root
.
Is there a clean way to temporarilly map that foo
named volume on the host's /tmp/foo
path so I can do whatever I want to be doing and then removing that mapping?
I didn't find a way to map the volume to the host so I could rsync.
The next possible clean way was to start a container, map the host's ssh key and known_hosts
into /root/.ssh/
, install rsync, and rsync from there.
docker run \
--rm \
--name temp-container-for-volume-rsync \
--volume foo:/vol \
--volume ~/.ssh:/root/.ssh \
alpine \
sh -c 'apk add --no-cache openssh-client rsync && rsync -avzi /vol [email protected]:/tmp/'