Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 views
in Technique[技术] by (71.8m points)

docker - 如何在不使用存储库的情况下将Docker映像从一台主机复制到另一台主机(How to copy Docker images from one host to another without using a repository)

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

(如何在不使用存储库的情况下将Docker映像从一台计算机转移到另一台计算机,无论是私有的还是公共的?)

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.

(我习惯于在VirtualBox中播放和创建自己的映像,完成后,我尝试部署到其他计算机上以实际使用。)

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

(由于它基于自己的映像(例如Red Hat Linux),因此无法从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?

(看来保存/导出可以达到类似的目的,请参阅Docker中保存和导出之间有什么区别?)

, and I prefer the save command for my case.

(,对于我的情况,我更喜欢使用save命令。)

  ask by Larry Cai translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

(您将需要将Docker映像另存为tar文件:)

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 , scp or rsync (preferred for big files).

(然后使用常规文件传输工具(例如cpscprsync (对于大文件而言首选))将映像复制到新系统。)

After that you will have to load the image into Docker:

(之后,您必须将映像加载到Docker中:)

docker load -i <path to image tar file>

PS: You may need to sudo all commands.

(PS:您可能需要对所有命令进行sudo 。)

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

(编辑:您应该使用-o添加文件名(而不仅仅是目录),例如:)

docker save -o c:/myfile.tar centos:16

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...