Containers not restarted after update with restart always in docker-compose.yml

前端 未结 4 1412
孤街浪徒
孤街浪徒 2021-01-15 02:35

I have some containers which all of them have the always restart value in the docker-compose file like this:

version: "3.7"
services:

  container:
         


        
4条回答
  •  萌比男神i
    2021-01-15 03:42

    always Always restart the container if it stops. If it is manually stopped, it is restarted only when the Docker daemon restarts, or the container itself is manually restarted.

    unless-stopped Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after the Docker daemon restarts.

    If you had an already running container that you wanted to change the restart policy for, you could use the docker update command to change that, and the below command will ensure all currently running containers will be restarted unless stopped

    $ docker update --restart unless-stopped $(docker ps -q)
    

    NOTE: Keep the following in mind when using restart policies

    1. A restart policy only takes effect after a container starts successfully. In this case, starting successfully means that the container is up for at least 10 seconds and Docker has started monitoring it. This prevents a container that does not start at all from going into a restart loop.

    2. If you manually stop a container, its restart policy is ignored until the Docker daemon restarts, or the container is manually restarted. This is another attempt to prevent a restart loop.

    3. Restart policies only apply to containers. Restart policies for swarm services are configured differently

    Documentation

提交回复
热议问题