Skip to content

Instantly share code, notes, and snippets.

@Midnighter
Last active August 14, 2025 09:34
Show Gist options
  • Save Midnighter/8948f63f8788abe08932913ecbfffcbb to your computer and use it in GitHub Desktop.
Save Midnighter/8948f63f8788abe08932913ecbfffcbb to your computer and use it in GitHub Desktop.
Pull a specific Docker volume from a remote host via SSH.
#!/usr/bin/env bash
set -euxo pipefail
host=${1?The first argument needs to be an SSH remote host.}
volume=${2?The second argument needs to be a Docker volume name.}
ssh ${host} \
"docker run --rm -v ${volume}:/from alpine ash -c 'cd /from ; tar -cf - . '" | \
docker run --rm -i -v ${volume}:/to alpine ash -c 'cd /to ; tar -xpvf - '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment