How to copy Docker images from one host to another

2019-01-01 11:20发布

How do I transfer a Docker image from one machine to another one without using a repository, no matter private or public?

I am used to play and create my own image in VirtualBox, and when it is finished, I try to deploy to other machines to have real usage.

Since it is based on own based image (like Red Hat Linux), it cannot be recreated from a Dockerfile.

Are there simple commands I can use? Or another solution?

It seems save/export can achieve a similar purpose, see What is the difference between save and export in Docker?, and I prefer the save command for my case.

标签: docker
14条回答
裙下三千臣
2楼-- · 2019-01-01 12:21

You may use sshfs:

$ sshfs user@ip:/<remote-path> <local-mount-path>
$ docker save <image-id> > <local-mount-path>/myImage.tar
查看更多
皆成旧梦
3楼-- · 2019-01-01 12:22

You will need to save the Docker image as a tar file:

docker save -o <path for generated tar file> <image name>

Then copy your image to a new system with regular file transfer tools such as cp or scp. After that you will have to load the image into Docker:

docker load -i <path to image tar file>

PS: You may need to sudo all commands.

EDIT: You should add filename (not just directory) with -o, for example:

docker save -o c:/myfile.tar centos:16
查看更多
登录 后发表回答