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

查看:30
本文介绍了如何在不使用存储库的情况下将 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>

然后使用常规文件传输工具将图像复制到新系统,例如 cpscprsync(大文件首选).之后,您必须将图像加载到 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天全站免登陆