Docker可以轻松停止和重启容器.它还能够暂停然后取消暂停容器.Docker文档声明
退出容器时,将保留文件系统的状态及其退出值.您可以启动,停止和重新启动容器.进程从头开始重新启动(它们的内存状态不会保留在容器中),但文件系统就像容器停止时一样.
我通过建立一个带memcached运行的容器来测试它,然后将值写入memcache
在文档的某个地方 - 我再也找不到精确的文档 - 我读到停止的容器不消耗CPU或内存.然而:
对于任何可能澄清这些问题的人,我都是最有责任的.
Jav*_*oso 17
我不是docker core的专家,但我会尝试回答其中的一些问题.
- 我认为文件系统状态保留的事实意味着容器仍然占用主机文件系统上的一些空间?
是.Docker保存所有容器和图像数据/var/lib/docker.保存容器和图像数据的默认方法是使用aufs.每层的数据保存在/var/lib/docker/aufs/diff.创建新容器时,还会使用is文件夹创建新图层,并存储源图像图层的更改.
- 是否存在与系统中已停止容器的10秒甚至100秒相关的性能损失(主机磁盘空间消耗除外)?例如,它是否使Docker更难以启动和管理新容器?
据我所知,它不应该是任何表演.当您停止容器时,docker守护程序会将SIGTERM和SIGKILL发送到该容器的所有进程,如docker CLI文档中所述:
Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
Stop a running container by sending SIGTERM and then SIGKILL after a grace period
-t, --time=10 Number of seconds to wait for the container to stop before killing it. Default is 10 seconds.
3.And finally, if Paused containers retain their memory state when Unpaused - as demonstrated by their ability to remember memcached keys - do they have a different impact on CPU and memory?
As @Usman said, docker implements pause/unpause using the cgroup freezer. If I'm not wrong, when you put a process in the freezer (or its cgroup), you block the execution of new task of that process from the kernel task scheduler (i.e.: it stops the process), but you don't kill them and they keep consuming the memory they are using (although the Kernel may move that memory to swap or to solid disk). And the CPU resources used by a paused container I would consider insignificant. For more information about this I would check the pull request of this feature, Docker issue #5948
| 归档时间: |
|
| 查看次数: |
2779 次 |
| 最近记录: |