Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? See journal
journalctl -xeu docker
Nov 15 14:42:36 1eegram systemd[1]: Starting Docker Application Container Engine...
░░ Subject: A start job for unit docker.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit docker.service has begun execution.
░░
░░ The job identifier is 1511.
Nov 15 14:42:36 1eegram dockerd[2364]: time="2023-11-15T14:42:36.469366577+09:00" level=info msg="Starting up"
Nov 15 14:42:37 1eegram dockerd[2364]: failed to start daemon: error while opening volume store metadata database (/var/lib/docker/volumes/metadata.db): ti>
Nov 15 14:42:37 1eegram systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ An ExecStart= process belonging to unit docker.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Nov 15 14:42:37 1eegram systemd[1]: docker.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ The unit docker.service has entered the 'failed' state with result 'exit-code'.
Nov 15 14:42:37 1eegram systemd[1]: Failed to start Docker Application Container Engine.
░░ Subject: A start job for unit docker.service has failed
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit docker.service has finished with a failure.
░░
░░ The job identifier is 1511 and the job result is failed.
Nov 15 14:42:47 1eegram systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
- Duplicated pid
- Already mounted /var/lib/docker
- Too fast restart dockerd
so, execute script this:
ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh
- All stop docker
sudo systemctl stop '*docker*'
- Daemon reloading
sudo systemctl daemon-reload
- Restart and start pre-start scripts
sudo systemctl start docker
- See status
sudo systemctl status '*docker*'
ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh
sudo systemctl stop '*docker*'
sudo systemctl daemon-reload
sudo systemctl start docker
Add some lines like below:
[Service]
...
ExecStartPre=/bin/rm -f /var/run/docker.pid
ExecStartPre=/bin/sh -c 'ps axf | grep docker | grep -v grep | awk \'{print "kill -9 " $1}\' | sh'
# ps axf | grep docker | grep -v grep | awk '{print "kill -9 " $1}' | sudo sh
...
TimeoutStartSec=10
RestartSec=10
Restart=always
...