marius
marius

Reputation: 1442

Best way to copy files from Docker volume on remote server to local host?

I've got,

  1. My laptop
  2. A remote server I can SSH into which has a Docker volume inside of which are some files I'd like to copy to my laptop.

What is the best way to copy these files over? Bonus points for using things like rsync, etc.. which are fast / can resume / show me progress and not writing any temporary files.

Note: my user on the remote server does not have permission to just scp the data straight out of the volume mount in /var/lib/docker, although I can run any containers on there.

Upvotes: 6

Views: 2580

Answers (2)

suda
suda

Reputation: 2644

Having this problem, I created dvsync which uses ngrok to establish a tunnel that is being used by rsync to copy data even if the machine is in a private VPC. To use it, you first start the dvsync-server locally, pointing it at the source directory:

$ docker run --rm -e NGROK_AUTHTOKEN="$NGROK_AUTHTOKEN" \
  --mount source=MY_DIRECTORY,target=/data,readonly \
  quay.io/suda/dvsync-server

Note, you need the NGROK_AUTHTOKEN which can be obtained from ngrok dashboard. Then start the dvsync-client on the target machine:

docker run -e DVSYNC_TOKEN="$DVSYNC_TOKEN" \
  --mount source=MY_TARGET_VOLUME,target=/data \
  quay.io/suda/dvsync-client

The DVSYNC_TOKEN can be found in dvsync-server output and it's a base64 encoded private key and tunnel info. Once the data has been copied, the client wil exit.

Upvotes: 2

Auzias
Auzias

Reputation: 3798

I'm not sure about the best way of doing so, but if I were you I would run a container sharing the same volume (in read-only -- as it seems you just want to download the files within the volume) and download theses.

This container could be running rsync as you wish.

Upvotes: 1

Related Questions