dockersignalsrestart

Restart policies in docker container


I enabled docker container to restart automatically during crashes/system reboots etc.

For this we applied the docker restart policy to always for an already running container .

Sent a SIGHUP signal but the container did not stated automatically

      sudo docker kill --signal=SIGHUP 5b61a7735329
      5b61a7735329
      $ sudo docker ps
      CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

On restarting the docker container using below command , the container process starts automatically as verified by docker ps

      $ sudo systemctl restart docker
  1. Any suggestions why it is not starting automatically when we manually send the SIGHUP signal.
  2. Will it automatically restart for any docker failures ?

Solution

  • always: Always restart a stopped container unless the container was stopped explicitly
    

    You stopped it with docker kill. You should use "on-failure". SIGHUP is not a normal exit and should trigger a restart.

    on-failure: Restart the container if it exited with a non-zero exit code or if the docker daemon restarts
    

    ...