0

我按照 Saied Kazemi 关于使用 criu 的 docker 暂停和恢复的说明,并使用https://github.com/boucher/docker/tree/cr-defunct(基于 Ross Boucher 的反馈)从源代码构建 1.10.0-dev 以获取检查点/恢复功能。

我现在正在尝试使用 docker-proxy (github.com/edmodo/docker-proxy),后者又依赖 go-dockerclient (github.com/fsouza/go-dockerclient) 来获取有关正在创建的容器的指示等.

我的问题更具体到 docker 守护进程发送到 go-dockerclient 的底层触发器。当容器被创建、启动或停止时,会收到相应的指示符。

但是,当我使用还原时,我没有看到我希望看到的内容。也许我不完全理解恢复是如何工作的。我在调试模式下运行了 docker 守护进程,看看发生了什么

我首先检查一个正在运行的容器a1作为

docker checkpoint --image-dir=/tmp/ABC --leave_running a1

守护程序的相应调试是

DEBU[0036] Calling POST /v1.22/containers/a1/checkpoint 
DEBU[0036] POST /v1.22/containers/a1/checkpoint         
DEBU[0036] form data {"ImagesDirectory":"/tmp/ABC","LeaveRunning":true,"WorkDirectory":""} 
DEBU[0036] Using CRIU 20000 at: criu                    
DEBU[0036] Using CRIU with following args: [swrk 3]     
DEBU[0036] Using CRIU in DUMP mode                      
DEBU[0036] CRIU option ImagesDirFd with value 22
<snip> .... I can paste this as well if needed        
DEBU[0036] CRIU option EmptyNs with value 1073741824  

a2然后,我创建一个新容器

docker create --name=a2 alpine-sshd

守护进程中创建的相应调试日志为:

DEBU[0051] Calling POST /v1.22/containers/create        
DEBU[0051] POST /v1.22/containers/create?name=a2        
DEBU[0051] form data:{"AttachStderr":true,"AttachStdin":false,"AttachStdout":true,"Cmd":null,"Domainname":"","Entrypoint":null,"Env":[],"HostConfig":{"Binds":null,"BlkioDeviceReadBps":null,"BlkioDeviceReadIOps":null,"BlkioDeviceWriteBps":null,"BlkioDeviceWriteIOps":null,"BlkioWeight":0,"BlkioWeightDevice":null,"CapAdd":null,"CapDrop":null,"CgroupParent":"","ConsoleSize":[0,0],"ContainerIDFile":"","CpuPeriod":0,"CpuQuota":0,"CpuShares":0,"CpusetCpus":"","CpusetMems":"","Devices":[],"Dns":[],"DnsOptions":[],"DnsSearch":[],"ExtraHosts":null,"GroupAdd":null,"IpcMode":"","Isolation":"","KernelMemory":0,"Links":null,"LogConfig":{"Config":{},"Type":""},"Memory":0,"MemoryReservation":0,"MemorySwap":0,"MemorySwappiness":-1,"NetworkMode":"default","OomKillDisable":false,"OomScoreAdj":0,"PidMode":"","PortBindings":{},"Privileged":false,"PublishAllPorts":false,"ReadonlyRootfs":false,"RestartPolicy":{"MaximumRetryCount":0,"Name":"no"},"SecurityOpt":null,"ShmSize":null,"UTSMode":"","Ulimits":null,"VolumeDriver":"","VolumesFrom":null},"Hostname":"","Image":"alpine-sshd","Labels":{},"OnBuild":null,"OpenStdin":false,"StdinOnce":false,"StopSignal":"SIGTERM","Tty":false,"User":"","Volumes":{},"WorkingDir":""} 
ERRO[0051] Couldn't run auplink before unmount: exec: "auplink": executable file not found in $PATH 
DEBU[0051] container mounted via layerStore: /var/lib/docker/0.0/aufs/mnt/a02ad092a4ae9d0ae40f26a8457fe8379e63a8362444aedb6d41c67d34b2cb83 
ERRO[0051] Couldn't run auplink before unmount: exec: "auplink": executable file not found in $PATH 

此时,a2容器已创建,但未运行。此创建会向 dockerclient 指示已创建容器,但未运行。docker ps -a并分别docker ps显示两个 (a1a2) 和一个 ( a1) 容器;正如预期的那样。

之后,我a2使用检查点图像恢复

docker restore --force=true --image-dir=/tmp/ABC a2

相应的还原调试是:

DEBU[0083] Calling POST /v1.22/containers/a2/restore    
DEBU[0083] POST /v1.22/containers/a2/restore?force=1    
DEBU[0083] form data {"ImagesDirectory":"/tmp/ABC","LeaveRunning":false,"WorkDirectory":""} 
DEBU[0083] container mounted via layerStore: /var/lib/docker/0.0/aufs/mnt/a02ad092a4ae9d0ae40f26a8457fe8379e63a8362444aedb6d41c67d34b2cb83 
DEBU[0083] Assigning addresses for endpoint a2's interface on network bridge 
DEBU[0083] RequestAddress(LocalDefault/172.17.0.0/16, <nil>, map[]) 
DEBU[0083] Assigning addresses for endpoint a2's interface on network bridge 
INFO[0083] No non-localhost DNS nameservers are left in resolv.conf. Using default external servers : [nameserver 8.8.8.8 nameserver 8.8.4.4] 
INFO[0083] IPv6 enabled; Adding default IPv6 external servers : [nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8844] 
DEBU[0083] Using CRIU 20000 at: criu                    
DEBU[0083] Using CRIU with following args: [swrk 3]     
DEBU[0083] Using CRIU in RESTORE mode                   
DEBU[0083] CRIU option ImagesDirFd with value 29        
<snip>.... I can paste this if needed
DEBU[0083] CRIU option EmptyNs with value 1073741824   

这将启动容器。但是,通过 dockerclient 的守护程序看不到任何指示符。两个容器都正常工作。

这是设计上缺乏指示吗?是否有其他方法可以触发容器已启动?我必须深入挖掘 go-dockerclient 看看我是否遗漏了什么

任何帮助都感激不尽。提前致谢

4

1 回答 1

0

此分支代表具有检查点恢复功能的 docker 最新工作版本:https ://github.com/boucher/docker/tree/cr-defunct

还有一个预编译版本:https ://github.com/boucher/docker/releases/tag/v1.10_2-16-16-experimental

我相信,虽然“开始”事件不会触发,但“恢复”事件应该由守护进程触发。

于 2016-05-10T12:52:53.220 回答