From 96f5776e04c678445b6fee6f23fc4bbe3ce37681 Mon Sep 17 00:00:00 2001 From: Qiutong Song Date: Sun, 20 Sep 2020 23:35:27 -0700 Subject: [PATCH] Add PIDFile to docker.service unit file to make systemd clean up pid file more reliably - What I did In docker.service unit file, add a PIDFile option with the default pid file path of docker. - Why I did In the case of a high churn process system there is an edge case where the process is killed and the process id is assigned to a new running process before systemd can restart the process and see that no process is running under the old pid. When the in-use PIDs is close to the system capacity, it's likely that the PID has been reused by some other process. The dockerd does a check to see if the pid file exist and the process id in the file is running[3]. In this case, docker will fail to restart since the pid file contains a valid, running process. So configuring the PIDFile in docker.service, systemd will help cleanup the pid file more reliably. - How I did it Updated the docker.service - How to verify it Try to simulate the high churn behavior. Signed-off-by: Qiutong Song --- systemd/docker.service | 3 +++ 1 file changed, 3 insertions(+) diff --git a/systemd/docker.service b/systemd/docker.service index a120c29574..cdabc1be3f 100644 --- a/systemd/docker.service +++ b/systemd/docker.service @@ -43,5 +43,8 @@ Delegate=yes # kill only the docker process, not all processes in the cgroup KillMode=process +# ensure to cleanup pid file when the daemon stops +PIDFile=/var/run/docker.pid + [Install] WantedBy=multi-user.target