title: What does Docker STOPSIGNAL do?
body: <p>I am trying to understand what exactly the <code>STOPSIGNAL</code> command in a dockerfile does. So according to the <a href="https://docs.docker.com/engine/reference/builder/#usage" rel="noreferrer">Docker Docs</a>:</p>
  
  <blockquote>
    <p>The STOPSIGNAL instruction sets the system call signal that will be
    sent to the container to exit. This signal can be a valid unsigned
    number that matches a position in the kernel’s syscall table, for
    instance 9, or a signal name in the format SIGNAME, for instance
    SIGKILL.</p>
  </blockquote>
  
  <p>With this explanation I understand that there is some signal that is sent to the docker container to tell inside applications to stop. But when I shutdown a running container with <code>sudo docker stop container-name</code>, doesn't it then automatically also stops everything that runs inside? I can type this command without getting any errors. Isn't it then redundant to explicitly define <code>STOPSIGNAL</code> inside a dockerfile?</p>
  
  <p>Looking at how <a href="https://github.com/nginxinc/docker-nginx/blob/f603bb3632ea6df0bc9da2179c18eb322c286298/mainline/stretch/Dockerfile#L21" rel="noreferrer">Nginx is built with a dockerfile</a>, the command <code>STOPSIGNAL SIGTERM</code> is used. But what does that exaclty mean? Would it break something to not define <code>STOPSIGNAL</code>?</p>