如何在不同主机之间移动 Docker 容器? [英] How to move Docker containers between different hosts?

查看:24
本文介绍了如何在不同主机之间移动 Docker 容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到将运行 docker 的容器从一个主机移动到另一个主机的方法.

I cannot find a way of moving docker running containers from one host to another.

有什么办法可以像我们处理图像一样将我的容器推送到存储库?目前,我没有使用数据卷来存储与在容器内运行的应用程序相关的数据.所以一些数据驻留在容器中,我想在重新设计设置之前保留这些数据.

Is there any way I can push my containers to repositories like we do for images ? Currently, I am not using data volumes to store the data associated with applications running inside containers. So some data resides inside containers, which I want to persist before redesigning the setup.

推荐答案

您无法将正在运行的 docker 容器从一台主机移动到另一台主机.

You cannot move a running docker container from one host to another.

您可以使用 docker commit 将容器中的更改提交到图像,将镜像移动到新主机上,然后使用 docker run.这将保留您的应用程序在容器内创建的所有数据.

You can commit the changes in your container to an image with docker commit, move the image onto a new host, and then start a new container with docker run. This will preserve any data that your application has created inside the container.

注意:它不保留存储在卷内的数据;您需要手动将数据卷移动到新主机.

Nb: It does not preserve data that is stored inside volumes; you need to move data volumes manually to new host.

这篇关于如何在不同主机之间移动 Docker 容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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