Skip to main content

Transfer Docker image between hosts

Solution form Stack Overflow:

Transferring a Docker image via SSH, bzipping the content on the fly:

docker save <image> | bzip2 | ssh user@host docker load

Note that docker load automatically decompresses images for you. It supports gzip, bzip2 and xz.

It's also a good idea to put pv in the middle of the pipe to see how the transfer is going:

docker save <image> | bzip2 | pv | ssh user@host docker load

Use gzip/gunzip when your network is fast and you can upload at 10 Mb/s and more -- because bzip won't be able to compress fast enough, gzip will be much faster (Thanks @Thomas Steinbach)

Use xz if you're on really slow network (e.g. mobile internet). xz offers a higher compression ratio (Thanks @jgmjgm)

Also consider using this neat trick by @vitalets:

docker save <image> | gzip | DOCKER_HOST=ssh://user@remotehost docker load