Synchronizing a Docker Image Without a Registry
This will be a shorter post than most, but I wanted to share a cool “trick” that I stumbled across. I have a small project that I don’t want to publish to any public Docker container registry, but that I also wanted to deploy onto a server of mine. This can actually be done pretty easily with the following
docker save $IMAGE |pv |ssh $REMOTE_HOST docker load
docker save
will save the image as a tarball, which can be saved as an image on the remote host using docker load
. All we have to do is stream this tarball over an ssh connection’s stdin, and it will be loaded (we also gain some peace of mind by viewing the progress with pv(1)
, but this is of course optional). docker load
also can handle several different compression schemes, so we can save ourselves some time by piping it through gzip
.
docker save $IMAGE |gzip |pv |ssh $REMOTE_HOST docker load
Pretty nifty!