gpt4 book ai didi

Docker - `docker run --restart always` 实际上是做什么的?

转载 作者:行者123 更新时间:2023-12-04 12:05:05 26 4
gpt4 key购买 nike

尽管 --restart 标志看起来简单明了,但我在试验时提出了许多问题:

  • 关于 ENTRYPOINT定义 - 重启期间实际定义的语义是什么?
  • 如果我 exec进入容器(我在 DDC 上)并杀死 -9 进程,它会重新启动,但如果我这样做 docker kill它不是。为什么?
  • 重新启动如何与共享数据容器/命名卷交互?
  • 最佳答案

    重启策略

    在 Docker 运行时使用 --restart 标志,您可以指定一个重启策略,用于在退出时应该或不应该重新启动容器。

    当容器上的重启策略处于事件状态时,它将在 docker ps 中显示为 Up 或 Restarting。使用 docker 事件查看生效的重启策略也很有用。

    docker run --always 

    Always restart the container regardless of the exit status. When you specify always, the Docker daemon will try to restart the container indefinitely. The container will also always start on daemon startup, regardless of the current state of the container.



    我向您推荐有关 的文档重启政策

    Documentation - Restart policies

    更新 Docker v19.03

    Restart policies (--restart)

    Use Docker’s --restart to specify a container’s restart policy. A restart policy > controls whether the Docker daemon restarts a container after exit. Docker supports the following restart policies:

    always Always restart the container regardless of the exit status. When you specify always, the Docker daemon will try to restart the container indefinitely. The container will also always start on daemon startup, regardless of the current state of the container.


    $ docker run --restart=always redis

    Documentation - Restart policies

    关于Docker - `docker run --restart always` 实际上是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41555884/

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