dockerd refuses to start because /var/run/docker.pid points at a live process
Your error
failed to start daemon, ensure docker is not running or delete /var/run/docker.pid: process with PID 1234 is still running1 more line it can showFix it fast
Most common cause, 1 of 2A Docker daemon is already running, so the second start is refused
Use the daemon that is running, or stop the service before starting dockerd by hand, and start the service again when you are done.
# keep the service and just use it
docker info
# or run a foreground daemon for debugging
sudo systemctl stop docker
sudo dockerd --debug
# Ctrl+C stops it; then bring the service back
sudo systemctl start dockerShort answer
failed to start daemon, ensure docker is not running or delete /var/run/docker.pid means dockerd found a live process at the PID in its pid file. Either a Docker daemon is already up, usually the systemd service, or the file is stale and another process now has that number. Check the PID before deleting the file. Docker Engine 28 and 29.
Which cause do you have?
Read the PID from the file and ask what that process is. A dockerd at that PID is cause 1. Any other program, or no dockerd anywhere in the process list, is cause 2.
cat /var/run/docker.pid
ps -o pid,comm,args -p "$(cat /var/run/docker.pid)"
pgrep -a dockerdThen find the line you see in this list and open its fix:
- 1A Docker daemon is already running, so the second start is refused
ps shows dockerd at the PID from the file, and systemctl reports the docker service as active - 2The pid file is stale and its PID now belongs to another process
ps shows some other program at that PID (or nothing obvious), and pgrep finds no dockerd at all
What does the error look like?
failed to start daemon, ensure docker is not running or delete /var/run/docker.pid: process with PID 1234 is still runningfailed to start daemon: pid file found, ensure docker is not running or delete /var/run/docker.pid
Cause 1 of 2
A Docker daemon is already running, so the second start is refused
You seeps shows dockerd at the PID from the file, and systemctl reports the docker service as active
Check
Before it writes its own PID, dockerd reads the existing pid file (by default /var/run/docker.pid) and stops with this error when that PID is alive. The usual trigger is typing sudo dockerd to see logs or try a flag while the packaged service is already running; Docker notes that on Ubuntu and Debian the service often starts automatically. Two start mechanisms, such as a service plus a boot script, collide in the same way.
systemctl status docker --no-pagerFix
Use the daemon that is running, or stop the service before starting dockerd by hand, and start the service again when you are done.
# keep the service and just use it
docker info
# or run a foreground daemon for debugging
sudo systemctl stop docker
sudo dockerd --debug
# Ctrl+C stops it; then bring the service back
sudo systemctl start dockerVerify
Only one dockerd is in the process list and the client reaches it.
pgrep -a dockerd
docker info --format '{{.ServerVersion}}'Confirmed by raw.githubusercontent.com
Cause 2 of 2
The pid file is stale and its PID now belongs to another process
You seeps shows some other program at that PID (or nothing obvious), and pgrep finds no dockerd at all
Check
dockerd removes its pid file on a clean shutdown, through a deferred cleanup in its start routine, so a crash, a kill -9 or a power cut leaves the file behind. On Linux the liveness test only checks whether /proc/<PID> exists, which means any process that later received the same number, even an unrelated one, counts as running. So once the number from a leftover file has been given to a new process, dockerd refuses to start even though no daemon is running.
cat /proc/$(cat /var/run/docker.pid)/commFix
Make sure no dockerd is running, then remove the stale file and start Docker the normal way.
pgrep -x dockerd || sudo rm /var/run/docker.pid
sudo systemctl start dockerVerify
The service is active, the pid file now holds the PID of the new dockerd, and ps confirms it.
systemctl is-active docker
ps -o comm= -p "$(cat /var/run/docker.pid)"Confirmed by raw.githubusercontent.com
How do I stop it coming back?
- Start Docker through one mechanism only: the systemd service, or a boot script, never both.
- When you need an extra daemon for testing, give it its own --pidfile, --data-root, --exec-root and --host, which the dockerd reference lists as required for each daemon on one host.
- Stop the daemon with systemctl stop docker instead of kill -9, so it can remove its pid file on the way out.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, Dispatch Pro.