docker 问题处理

本页内容

docker 问题处理

docker 无法启动

打开服务器输入docker ps,输出错误
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

怀疑是不是docker.services 部署没成功,systemctl start docker 启动 docker,结果服务器还是报错

Job for docker.service failed because the control process exited with error code.
See “systemctl status docker.service” and “journalctl -xe” for details.

systemctl status docker.service 输出日志:

 1● docker.service - Docker Application Container Engine
 2     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
 3     Active: failed (Result: exit-code) since Thu 2022-08-04 11:43:05 CST; 2min 57s ago
 4TriggeredBy: ● docker.socket
 5       Docs: https://docs.docker.com
 6    Process: 30432 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 7   Main PID: 30432 (code=exited, status=1/FAILURE)
 8
 9Aug 04 11:43:05 master01 systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
10Aug 04 11:43:05 master01 systemd[1]: Stopped Docker Application Container Engine.
11Aug 04 11:43:05 master01 systemd[1]: docker.service: Start request repeated too quickly.
12Aug 04 11:43:05 master01 systemd[1]: docker.service: Failed with result 'exit-code'.
13Aug 04 11:43:05 master01 systemd[1]: Failed to start Docker Application Container Engine.

journalctl -xe 输出日志:

 1Aug 04 11:46:49 master01 systemd[1]: Starting Docker Socket for the API.
 2-- Subject: A start job for unit docker.socket has begun execution
 3-- Defined-By: systemd
 4-- Support: http://www.ubuntu.com/support
 5--
 6-- A start job for unit docker.socket has begun execution.
 7--
 8-- The job identifier is 58900.
 9Aug 04 11:46:49 master01 systemd[1]: Listening on Docker Socket for the API.
10-- Subject: A start job for unit docker.socket has finished successfully
11-- Defined-By: systemd
12-- Support: http://www.ubuntu.com/support
13--
14-- A start job for unit docker.socket has finished successfully.
15--
16-- The job identifier is 58900.
17Aug 04 11:46:49 master01 systemd[1]: Starting Docker Application Container Engine...
18-- Subject: A start job for unit docker.service has begun execution
19-- Defined-By: systemd
20-- Support: http://www.ubuntu.com/support
21--
22-- A start job for unit docker.service has begun execution.
23--
24-- The job identifier is 58830.
25Aug 04 11:46:49 master01 dockerd[30544]: unable to configure the Docker daemon with file /etc/docker/daemon.json: EOF
26Aug 04 11:46:49 master01 systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
27-- Subject: Unit process exited
28-- Defined-By: systemd
29-- Support: http://www.ubuntu.com/support
30--
31-- An ExecStart= process belonging to unit docker.service has exited.
32--
33-- The process' exit code is 'exited' and its exit status is 1.
34Aug 04 11:46:49 master01 systemd[1]: docker.service: Failed with result 'exit-code'.
35-- Subject: Unit failed
36-- Defined-By: systemd
37-- Support: http://www.ubuntu.com/support
38--
39-- The unit docker.service has entered the 'failed' state with result 'exit-code'.
40Aug 04 11:46:49 master01 systemd[1]: Failed to start Docker Application Container Engine.
41-- Subject: A start job for unit docker.service has failed
42-- Defined-By: systemd
43-- Support: http://www.ubuntu.com/support
44--
45-- A start job for unit docker.service has finished with a failure.
46--
47-- The job identifier is 58830 and the job result is failed.
48Aug 04 11:46:49 master01 sudo[30535]: pam_unix(sudo:session): session closed for user root

我运行了:

sudo dockerd –debug

输出日志:
unable to configure the Docker daemon with file /etc/docker/daemon.json: EOF

  • 解决方法:
1#如果 /etc/docker/daemon.json 为空
2vim /etc/docker/daemon.json
3# 添加
4{
5}
6#保存退出
7:wq

重启 docker

systemctl restart docker