Skip to content

Instantly share code, notes, and snippets.

@Midnighter
Last active August 14, 2025 09:35
Show Gist options
  • Select an option

  • Save Midnighter/84ae06e1070c0a9567be7150481eb7d1 to your computer and use it in GitHub Desktop.

Select an option

Save Midnighter/84ae06e1070c0a9567be7150481eb7d1 to your computer and use it in GitHub Desktop.
Push a local Docker volume to 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.}
docker run --rm -v ${volume}:/from alpine ash -c \
'cd /from ; tar -cf - . ' | \
ssh ${host} \
"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