背景
systemctl start docker失败,输出如下:
systemctl restart docker
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
分析
根据输出,可以执行systemctl status docker
或者journalctl -xeu docker.service
来分析报错。
首先执行systemctl status docker
,输出如下:
systemctl status docker
× docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2023-04-27 03:53:32 UTC; 2h 18min ago
TriggeredBy: × docker.socket
Docs: https://docs.docker.com
Process: 1820 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 1820 (code=exited, status=1/FAILURE)
CPU: 89ms
Apr 27 03:53:32 xxx systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
Apr 27 03:53:32 xxx systemd[1]: Stopped Docker Application Container Engine.
Apr 27 03:53:32 xxx systemd[1]: docker.service: Start request repeated too quickly.
Apr 27 03:53:32 xxx systemd[1]: docker.service: Failed with result 'exit-code'.
Apr 27 03:53:32 xxx systemd[1]: Failed to start Docker Application Container Engine.
Apr 27 03:53:59 xxx systemd[1]: docker.service: Start request repeated too quickly.
Apr 27 03:53:59 xxx systemd[1]: docker.service: Failed with result 'exit-code'.
Apr 27 03:53:59 xxx systemd[1]: Failed to start Docker Application Container Engine
没找到什么有用的信息,只知道它重启了很多次。
然后执行journalctl -xeu docker.service
,输出如下:
Apr 27 06:12:05 xxx dockerd[2055]: unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid character 'â' after top-level value
Apr 27 06:12:05 xxx 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.
Apr 27 06:12:05 xxx 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'.
Apr 27 06:12:05 xxx 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 3097 and the job result is failed.
Apr 27 06:12:08 xxx systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ Automatic restarting of the unit docker.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Apr 27 06:12:08 xxx systemd[1]: Stopped Docker Application Container Engine.
我们发现,是配置文件daemon.json中有非法字符:
invalid character ‘â’ after top-level value
我们把配置内容复制到本地编辑器,检查并清理下内容,再拷贝到服务器上。
然后执行
dos2unix daemon.json
把回车键清理一下