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

查看:73
本文介绍了如何在不使用存储库的情况下将Docker映像从一台主机复制到另一台主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我在VirtualBox中创建自己的映像,

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

由于它基于我自己的映像(如Red Hat Linux),因此它无法完成实际使用。从Dockerfile重新创建。我的dockerfile不太容易移植。

Since it is based on my own based image (like Red Hat Linux), it cannot be recreated from a Dockerfile. My dockerfile isn't easily portable.

我可以使用简单的命令吗?还是其他解决方案?

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

推荐答案

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

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

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

然后使用常规文件传输工具(例如)将图像复制到新系统cp scp rsync (适用于大文件)。之后,您必须将映像加载到Docker中:

Then copy your image to a new system with regular file transfer tools such as cp, scp or rsync(preferred for big files). After that you will have to load the image into Docker:

docker load -i <path to image tar file>

PS:您可能需要全部 sudo

PS: You may need to sudo all commands.

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

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

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

这篇关于如何在不使用存储库的情况下将Docker映像从一台主机复制到另一台主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆