Docker中的容器迁移 [英] Container migration in Docker

查看:523
本文介绍了Docker中的容器迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个简单的教程来测试两个VM之间的容器迁移.我看过一些视频,但是它们并没有确切显示它们是如何做到的,或者我自己却没有真正找到任何好的教程. 我是Docker的新手,所以我只想测试这种迁移的工作方式.因此,非常高兴您可以给我一些教程/链接,清楚地说明如何进行操作. 非常感谢您的帮助,谢谢:)

I am searching for a simple tutorial to test container migration between two VMs. I have seen some videos but they do not show exactly how they did that or didn't actually found any good tutorial by myself. I am new to docker so I just wanted to test how this migration works. So, it will be very nice you can give me some tutorials/links that clearly explains how to do it. Your help will be really appreciated, thanks :)

推荐答案

我真的很支持Farhood的回答.我想在这里详细写.首先,由于CRIU与Docker的集成,Docker支持容器的检查点和还原".但是,它处于实验模式,因此请小心.

I really endorse Farhood's answer. I want to write here in detail. At First, Docker supports "checkpoint and restore" of a contianer, thanks to the CRIU integration with Docker. But, it is in the experimental mode so be careful.

什么是CRIU? CRIU是Linux操作系统的软件工具.使用此工具,您可以冻结正在运行的应用程序(或其一部分),并将其检查点作为磁盘上文件的集合.然后,您可以使用这些文件还原应用程序,并完全按照冻结期间的方式运行该应用程序.

What is CRIU? CRIU is a software tool for the Linux operating system. with this tool, you can freeze a running application (or part of it) and checkpoint it as a collection of files on disk. You can then use the files to restore the application and run it exactly as it was during the time of the freeze.

检查点/还原的应用

  • 使用此功能,您可以检查应用程序并将文件(从检查点复制)到目标计算机,并使用称为实时迁移的文件

您可以对应用程序进行检查,并以以前的状态还原该应用程序,该状态不过是快照.

You can take a checkpoint of an application and restore the application in the previous state which is nothing but the snapshotting.

检查点和还原"可用于调试应用程序.

"Checkpointing and restoring" can be used in debugging of an application. all processes of the application are checkpointed just before a bug and later restarted (possibly on a single host) for debugging.

优化启动时间:在操作系统的启动过程中检查点,下一次,该检查点可用于启动操作系统.

Optimize boot time: Checkpoint the boot process of an OS and next time, this checkpoint can be used to start an OS.

当前, CRIU 是唯一可用于检查点和还原容器的工具.我将向您展示上述操作的简单步骤.

Currently, CRIU is the only tool available to checkpoint and restore a container. I'll show you simple steps for the above operation.

步骤1:启用实验功能(包括CRIU).

Step 1: Enable experimental features (incl. CRIU).

echo "{\"experimental\": true}" >> /etc/docker/daemon.json
systemctl restart docker

步骤2:让我们部署一个简单的容器来打印数字.

Step 2: Let's deploy a simple container which print numbers.

docker run -d --name looper --security-opt seccomp:unconfined busybox  \
         /bin/sh -c 'i=0; while true; do echo $i; i=$(expr $i + 1); sleep 1; done'

第3步:让我们通过打印日志来验证应用程序正在运行.

Step 3: Let's verify the application is running by printing the logs.

 docker logs looper

第4步:使用以下Docker命令让我们检查点该容器.检查点的名称为"checkpoint1".我们将使用该名称来还原容器.

Step 4: Let's checkpoint this container with the following Docker command. Name of the checkpoint is "checkpoint1". We will use this name to restore the container.

docker checkpoint create looper checkpoint1

步骤4:您可以验证目录中的检查点.

Step 4: You can verify the checkpoint in the directory.

/var/lib/docker/containers/<container-ID>/checkpoints/<checkpoint name>/

步骤5:让我们使用以下Docker命令将容器还原到以前的状态.

Step 5: Let's restore the container to the previous state with the following Docker command.

docker start --checkpoint checkpoint1 looper

第6步::如何验证?在步骤5之前和之后打印容器的日志.

Step 6: How to verify? Print the logs of the container before and after the step 5.

(容器迁移)如何在其他VM中还原容器? 解决方案是将(容器的)检查点文件复制到目标节点,并使用它们来还原容器.目标节点应使Docker以实验模式运行.

(Container migration)How to restore the container in different VM? The solution is to copy the checkpointed files(of the container) to the target node and use them to restore the container. The target node should have Docker running in the experimental mode.

我特此附上有关Docker容器迁移的最新论文.您正在寻找这篇论文.

I am attaching hereby a recent paper on Docker container migration. You are looking for this paper.

http://www.cs.toronto.edu/~sahil /suneja-icdcs17​​.pdf

这篇关于Docker中的容器迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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