<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 13/01/2019 18:27, Nick Williams
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:D1D09E91-147F-4A4E-8099-62ED5EA43E07@nicholaswilliams.net">I’m
working on a Docker container to run my PDNS Authoritative
servers. I’m installing PDNS from <a
href="http://repo.powerdns.com" class="" moz-do-not-send="true">repo.powerdns.com</a>.
The Docker command that is run in `pdns_server`. The `docker stop`
command sends a `SIGTERM` to PID 1, waits some amount of time, and
then sends SIGKILL to force it to stop. It’s having to resort to
SIGKILL, because `pdns_server` doesn’t respond to `SIGTERM`. What
is the correct signal to tell PDNS to shut down?</blockquote>
The problem is not with pdns, it's with docker: strange things
happen if you run the application as pid 1. For an explanation see:
<a class="moz-txt-link-freetext" href="https://hackernoon.com/my-process-became-pid-1-and-now-signals-behave-strangely-b05c52cc551c">https://hackernoon.com/my-process-became-pid-1-and-now-signals-behave-strangely-b05c52cc551c</a>
<p>Solution: run a different pid 1 process whose job it is to launch
the application, such as tini:</p>
<p><a class="moz-txt-link-freetext" href="https://github.com/krallin/tini">https://github.com/krallin/tini</a></p>
<p>With a modern version of docker, tini is included. Just use the
--init flag to docker run, and it should all be fine.<br>
</p>
<p>Regards,</p>
<p>Brian.<br>
</p>
<p>P.S. You can easily show that pdns is happy with a SIGTERM when
you run it outside of docker.<br>
</p>
<p><tt>root@ns2:~# ps auxwww | grep pdns</tt><tt><br>
</tt><tt>
pdns 1612 0.0 0.7 677608 8064 ? Ssl 2018 16:37
/usr/sbin/pdns_server --guardian=no --daemon=no --disable-syslog
--write-pid=no</tt><tt><br>
</tt><tt>
root 25477 0.0 0.0 12944 968 pts/0 S+ 20:24 0:00
grep --color=auto pdns</tt><tt><br>
</tt><tt>
root@ns2:~# kill -TERM 1612</tt><tt><br>
</tt><tt>
root@ns2:~# ps auxwww | grep pdns</tt><tt><br>
</tt><tt>
root 25486 0.0 0.0 12944 940 pts/0 S+ 20:24 0:00
grep --color=auto pdns</tt><tt><br>
</tt><tt>
root@ns2:~#</tt></p>
<p>This is pdns-server 4.0.6 under Ubuntu 16.04, with mysql backend.</p>
</body>
</html>