gpt4 book ai didi

docker - 在 docker 上启用实时恢复并不能保持容器存活

转载 作者:行者123 更新时间:2023-12-02 18:18:35 25 4
gpt4 key购买 nike

我读了Enable Live Restore ,但是当我尝试它时。

ubuntu@ip-10-0-0-230:~$ cat /etc/docker/daemon.json 
{
"live-restore": true
}
我以分离模式启动了一个 nginx 容器。
sudo docker run -d  nginx
c73a20d1bb620e2180bc1fad7d10acb402c89fed9846f06471d6ef5860f76fb5


$sudo docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS

c73a20d1bb62 nginx "nginx -g 'daemon of…" 5 seconds ago Up 4
seconds
然后我停止了 dockerd
sudo systemctl stop snap.docker.dockerd.service
我检查了没有容器在运行
ps aux | grep nginx
之后,我重新启动了 docker 服务,但仍然没有任何容器。
任何想法?这个“启用实时恢复”是如何工作的?

最佳答案

来自 documentation ,修改后daemon.json (添加 "live-restore": true )您需要:

Restart the Docker daemon. On Linux, you can avoid a restart (and avoid any downtime for your containers) by reloading the Docker daemon. If you use systemd, then use the command systemctl reload docker. Otherwise, send a SIGHUP signal to the dockerd process.



您也可以这样做,但不建议这样做:

If you prefer, you can start the dockerd process manually with the --live-restore flag. This approach is not recommended because it does not set up the environment that systemd or another process manager would use when starting the Docker process. This can cause unexpected behavior.



看来你没有做这一步 .您说您已对 daemon.json 进行了修改并直接启动一个容器然后停止 dockerd .

为了使 Live Restore功能工作按照正确的顺序执行所有步骤:
  • 修改daemon.json通过添加 "live-restore": true
  • 重新加载 Docker 守护进程 使用命令:
    sudo systemctl reload docker

  • 那么使用您的示例尝试该功能(启动容器并使守护程序不可用)。

    我已经测试过,如果您按顺序执行以下步骤,它就可以工作:

    LiveRestore

    Docker version 19.03.2, build 6a30dfc 测试和 Ubuntu 19.10 (Eoan Ermine)
    你已经通过 snap 安装了 Docker : snap.docker.dockerd.service
    不幸的是, 不推荐,因为 snap model is not fully compatible with Docker .此外, docker-snap不再由 Docker, Inc 维护.用户在通过 snap 安装 Docker 时会遇到一些问题,请参阅 1 2

    您应该通过以下命令删除 snap Docker 安装以避免任何潜在的重叠安装问题:
    sudo snap remove docker --purge

    然后使用 official way 安装 Docker然后尝试 Live Restore按照上述步骤操作。

    重新启动守护程序时也要小心,文档说:

    Live restore upon restart

    The live restore option only works to restore containers if the daemon options, such as bridge IP addresses and graph driver, did not change. If any of these daemon-level configuration options have changed, the live restore may not work and you may need to manually stop the containers.



    还有关于停机时间:

    Impact of live restore on running containers

    If the daemon is down for a long time, running containers may fill up the FIFO log the daemon normally reads. A full log blocks containers from logging more data. The default buffer size is 64K. If the buffers fill, you must restart the Docker daemon to flush them.

    On Linux, you can modify the kernel’s buffer size by changing /proc/sys/fs/pipe-max-size.

    关于docker - 在 docker 上启用实时恢复并不能保持容器存活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59646097/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com