Sometimes you want to transfer docker images between two linux hosts over SSH. Supposing images are gonna be transferred to 2nd host, There are two options to do that:
- Push image to the 2nd host
- Pull image from the 1st host
Here are the Steps:
Save Image {> Compress} > SSH to 2nd Host ({> Decompress} > Load Image)
There has to be an ssh service running on 2nd host.
Compression/Decompression steps are optional and you can ignore them. Any set of tools can be used here (e.g. gzip/gunzip, bzip2/bunzip2, ...). Compressor has to be available on 1st host and Decompressor on 2nd host
- No compression:
docker save alpine:latest | ssh hostname.2nd "docker load"
- Compression with gzip:
docker save alpine:latest | gzip | ssh hostname.2nd "gunzip | docker load"
- Compression with bzip:
docker save alpine:latest | bzip2 | ssh hostname.2nd "bunzip2 | docker load"
Here are the Steps:
SSH to 1st Host (> Save Image {> Compress}) {> Decompress} > Load Image
There has to be an ssh service running on 1st host
Compression/Decompression steps are optional and you can ignore them. Any set of tools can be used here (e.g. gzip/gunzip, bzip2/bunzip2, ...). Compressor has to be available on 1st host and Decompressor on 2nd host
- No compression:
ssh hostname.1st "docker save alpine:latest" | docker load
- Compression with gzip:
ssh hostname.1st "docker save alpine:latest | gzip" | gunzip | docker load
- Compression with bzip:
ssh hostname.1st "docker save alpine:latest | bzip2" | bunzip2 | docker load