错误信息

根据菜鸟教程安装docker安装成功之后,通过docker --version也能输出docker版本,但是在启动docker的时候sudo systemctl start docker,就提示如下错误信息

Authorization not available. Check if polkit service is running or see debug message for more information.
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.

分析原因

查看docker启动失败的日志
  1. 使用sudo systemctl status docker查看

● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Tue 2024-07-16 14:23:41 CST; 2min 29s ago
Docs: https://docs.docker.com
Process: 25259 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 25259 (code=exited, status=1/FAILURE)
Jul 16 14:23:39 systemd[1]: Failed to start Docker Application Container Engine.
Jul 16 14:23:39 systemd[1]: Unit docker.service entered failed state.
Jul 16 14:23:39 systemd[1]: docker.service failed.
Jul 16 14:23:41 systemd[1]: docker.service holdoff time over, scheduling r…rt.
Jul 16 14:23:41 systemd[1]: Stopped Docker Application Container Engine.
Jul 16 14:23:41 systemd[1]: start request repeated too quickly for docker…ice
Jul 16 14:23:41 systemd[1]: Failed to start Docker Application Container Engine.
Jul 16 14:23:41 systemd[1]: Unit docker.service entered failed state.
Jul 16 14:23:41 systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

  1. 使用sudo journalctl -eu docker查看

Jul 16 14:23:36 dockerd[25244]: unable to configure the Docker daemon with file
Jul 16 14:23:36 systemd[1]: docker.service: main process exited, code=exited, st
Jul 16 14:23:36 systemd[1]: Failed to start Docker Application Container Engine.
Jul 16 14:23:36 systemd[1]: Unit docker.service entered failed state.
Jul 16 14:23:36 systemd[1]: docker.service failed.
Jul 16 14:23:38 systemd[1]: docker.service holdoff time over, scheduling restart
Jul 16 14:23:38 systemd[1]: Stopped Docker Application Container Engine.
Jul 16 14:23:38 systemd[1]: Starting Docker Application Container Engine…

解决办法

  1. 查看docker版本,docker --version

Docker version 26.1.4, build 5650f9b

  1. 使用sudo dockerd查看错误的原因,输出日志如下
unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives don't match any configuration option: oom-score-adjust

从上面的信息可以看出是因为配置文件中的oom-score-adjust参数有问题,我们先暂时删除,再用sudo dockerd重新验证一次

INFO[2024-07-16T15:01:31.700996310+08:00] Starting up                                  
INFO[2024-07-16T15:01:31.970802533+08:00] [graphdriver] trying configured driver: overlay2 
failed to start daemon: error initializing graphdriver: overlay2: unknown option overlay2.override_kernel_check: overlay2

由于文件系统不支持overlay2设置,删除所有和overlay2相关的设置

    "storage-driver": "overlay2",
    "storage-opts": [
        "overlay2.override_kernel_check=true",
        "overlay2.size=5G"
        ],

继续验证sudo dockerd

INFO[2024-07-16T15:08:10.545440357+08:00] Starting up
INFO[2024-07-16T15:08:10.967289150+08:00] [graphdriver] using prior storage driver: overlay2
INFO[2024-07-16T15:08:10.999479909+08:00] Loading containers: start.
INFO[2024-07-16T15:08:11.965473584+08:00] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address
INFO[2024-07-16T15:08:12.285538728+08:00] Loading containers: done.
WARN[2024-07-16T15:08:12.412564167+08:00] WARNING: bridge-nf-call-iptables is disabled
WARN[2024-07-16T15:08:12.412748144+08:00] WARNING: bridge-nf-call-ip6tables is disabled
INFO[2024-07-16T15:08:12.413248439+08:00] Docker daemon commit=de5c9cf containerd-snapshotter=false storage-driver=overlay2 version=26.1.4
INFO[2024-07-16T15:08:12.413557627+08:00] Daemon has completed initialization
INFO[2024-07-16T15:08:12.672481923+08:00] API listen on /var/run/docker.sock

可以看到已经没有任何错误信息了

  1. 重新启动docker
sudo systemctl start docker
  1. 将当前用户添加到docker组
#创建docker组
sudo groupadd docker
#将当前登录用户添加到docker组
sudo usermod -aG docker $USER

Authorization not available. Check if polkit service is running or see debug message for more information.

参考

  1. https://stackoverflow.com/questions/49110092/failed-to-start-docker-application-container-engine
  2. https://www.runoob.com/docker/centos-docker-install.html
  3. https://stackoverflow.com/questions/39100641/docker-service-start-failed
  4. https://stackoverflow.com/questions/45335316/unable-to-configure-the-docker-daemon-with-file-etc-docker-daemon-json-eof
  5. https://stackoverflow.com/questions/59631045/docker-start-failed-after-adding-daemon-json-file
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐