Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PID 1 in Docker persistance

I have set up a Kippo server to run in a docker container. Everything runs fine,until you kill the container. Killing the container(by restarting the machine or through docker kill) makes it unusable with STDERR "Another twistd server is running, PID 1". How can I solve this problem? I don't have issues to reset the file system of the container or something like this because everything I want is logged to a database. Thank you very much

like image 885
spanagiot Avatar asked Dec 25 '22 14:12

spanagiot


1 Answers

Within Docker, each container runs in its own PID namespace. This means that the process started by the dockerfile will always be PID 1, and PIDs will count upwards from there.

twistd expects that PIDs are non-deterministic enough that it can check to see if another twistd is "already running" by simply comparing to see if the PID is the same. Since, in Docker, the PID will always be 1, this check always succeeds, and twistd thinks it shouldn't start up. If the container exits un-cleanly, twistd won't get the opportunity to clean up its .pid file, and the state will be preserved within the container's filesystem.

Since the Docker daemon will namespace containers and prevent two matching twistd processes from starting up at the same time anyway, the .pid file and its related checking is not actually useful at all, so you should disable it. You can disable it by changing your command line to include the --pidfile= option (exactly as such, nothing after the "=") before the plugin name. I'm not familiar with Kippo, but for twistd web this would be twistd --pidfile= web.

I hope that this helps!

like image 75
Glyph Avatar answered Jan 05 '23 19:01

Glyph