如何在不同主机之间移动Docker容器? [英] How to move Docker containers between different hosts?
问题描述
我找不到将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::它不会保留应用程序在容器内创建的所有数据。您需要手动将数据卷移动到新主机。
Nb: It does not preserve data that is stored inside volumes; you need to move data volumes manually to new host.
这篇关于如何在不同主机之间移动Docker容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!