Skip to content

Latest commit

 

History

History
19 lines (13 loc) · 1 KB

README.md

File metadata and controls

19 lines (13 loc) · 1 KB

docker-cp

Copy docker volumes between machines

This simple bash script allows you to copy docker volumes between remote/local machines!

Syntax:

docker-cp [source_hostname:]<source_volume> [dest_hostname:]<dest_volume>

Requirements:

  • You must be able to ssh into any remote hosts you name!

This script transfers volume files with a fairly simple mechanism:

  • It spins up an alpine container on the source machine, mounting the source volume
  • The alpine container writes a tarball to stdout, which is written to your local machine in a temporary directory
  • The temporary tarball is then fed into another alpine instance in the destination machine, which also mounts the named volume
  • The new alpine instance then extracts the tarball into the destination volume

Either (or both) the source or destination machines may be local, which is assumed if no hostname is specified for them. This is probably not the most efficient method for creating local-only copies of docker volumes but it will do that just fine.