Can I suspend and then resume Docker container?

2019-03-09 00:00发布

I would like to suspend Docker container and resume it after while. How this can be done? By suspending I mean that it should save the state of ongoing process (e.g. video encoding) and then resume it back at any time.

标签: docker
4条回答
Summer. ? 凉城
2楼-- · 2019-03-09 00:42

AFAIK right now it can't be done with pure docker but lxc supports that. I've play around little bit with docker and confirmed that this can be done with lxc-freeze -n <containtr.id> and to resume operations lxc-unfreeze -n <container.id> But in v0.2.0 docker ps gives you only shorten containter id even with -notrunc and lxc-ls output is empty on my system (strange, need to read more about it, as docker uses plain lxc-start with params so lxc-ps should print this). I found full container id with lxc-ps. It would be nice to add docker freeze command. Maybe it's time for me to learn some go :)

查看更多
别忘想泡老子
3楼-- · 2019-03-09 00:46

Docker has just released an (as yet) undocumented volumes and data storage feature set. tl;dr if you use the -v commandline option you can specify a path to map outside of the container to a special docker path (/var/lib/docker/volumes/{FULL_ID}) where FULL_ID can be found by docker inspect container_id. An example is docker run -d -v /data danielvf/myapp:1.0 runapp which would externalize the /data directory into a docker volume.

https://github.com/dotcloud/docker/issues/111

Roadmap for this feature: (doesn't yet document it's existence): https://github.com/dotcloud/docker/wiki/Volumes-&-persistent-data-storage

查看更多
4楼-- · 2019-03-09 00:52

As of Version 0.12.0, Docker supports PAUSE and UNPAUSE commands to pause and resume containers using cgroup freezer.

查看更多
登录 后发表回答