1. 按照网上的教程修改了 /usr/lib/systemd/system/docerk.service配置后,重启失败。修改/etc/docker/daemon.json 增加hosts后重启也是如此。反复操作了几次之后依旧启动报错。
[root@web-dev1 system]# systemctl daemon-reload [root@web-dev1 system]# systemctl start docker Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@web-dev1 system]# systemctl status docker.service ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: failed (Result: start-limit) since Thu 2021-09-02 08:51:20 CST; 1min 32s ago Docs: https://docs.docker.com Process: 20308 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock (code=exited, status=1/FAILURE) Main PID: 20308 (code=exited, status=1/FAILURE) Sep 02 08:51:17 web-dev1 systemd[1]: Failed to start Docker Application Container Engine. Sep 02 08:51:17 web-dev1 systemd[1]: Unit docker.service entered failed state. Sep 02 08:51:17 web-dev1 systemd[1]: docker.service failed. Sep 02 08:51:20 web-dev1 systemd[1]: docker.service holdoff time over, scheduling restart. Sep 02 08:51:20 web-dev1 systemd[1]: Stopped Docker Application Container Engine. Sep 02 08:51:23 web-dev1 systemd[1]: start request repeated too quickly for docker.service Sep 02 08:51:23 web-dev1 systemd[1]: Failed to start Docker Application Container Engine. Sep 02 08:51:23 web-dev1 systemd[1]: Unit docker.service entered failed state. Sep 02 08:51:23 web-dev1 systemd[1]: docker.service failed.
2. 解决方案,docker.service 14行标红项修改
[root@web-dev1 system]# vim /usr/lib/systemd/system/docker.service 1 [Unit] 2 Description=Docker Application Container Engine 3 Documentation=https://docs.docker.com 4 After=network-online.target firewalld.service containerd.service 5 Wants=network-online.target 6 Requires=docker.socket containerd.service 7 8 [Service] 9 Type=notify 10 # the default is not to use systemd for cgroups because the delegate issues still 11 # exists and systemd currently does not support the cgroup feature set required 12 # for containers run by docker 13 # ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock 14 ExecStart=/usr/bin/dockerd 15 ExecReload=/bin/kill -s HUP $MAINPID 16 TimeoutSec=0 17 RestartSec=2 18 Restart=always 19
然后修改daemon.json,追加hosts配置项
[root@web-dev1 system]# vim /etc/docker/daemon.json 1 { 2 "registry-mirrors": ["https://dockerhub.azk8s.cn","https://hub-mirror.c.163.com"], 3 "exec-opts": ["native.cgroupdriver=cgroupfs"], 4 "log-driver": "json-file", 5 "log-opts": {"max-size": "10m","max-file": "10"}, 6 "insecure-registries": ["1.1.1.1:2021"], 7 "hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"] 8 }
重启
[root@web-dev1 system]# systemctl daemon-reload
[root@web-dev1 system]# systemctl start docker
验证
[root@web-dev1 system]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE [root@web-dev1 system]# vim /etc/docker/daemon.json [root@web-dev1 system]# lsof -i:2375 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME dockerd 30865 root 9u IPv6 285808116 0t0 TCP *:2375 (LISTEN) [root@web-dev1 system]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2021-09-02 09:00:45 CST; 2min 24s ago Docs: https://docs.docker.com Main PID: 30865 (dockerd) Tasks: 13 Memory: 28.0M CGroup: /system.slice/docker.service └─30865 /usr/bin/dockerd Sep 02 09:00:44 web-dev1 dockerd[30865]: time="2021-09-02T09:00:44.901936855+08:00" level=info msg="ClientConn switching balancer to \"pick_first...dule=grpc Sep 02 09:00:44 web-dev1 dockerd[30865]: time="2021-09-02T09:00:44.915442870+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2" Sep 02 09:00:44 web-dev1 dockerd[30865]: time="2021-09-02T09:00:44.924126668+08:00" level=info msg="Loading containers: start." Sep 02 09:00:45 web-dev1 dockerd[30865]: time="2021-09-02T09:00:45.069987957+08:00" level=info msg="Default bridge (docker0) is assigned with an ... address" Sep 02 09:00:45 web-dev1 dockerd[30865]: time="2021-09-02T09:00:45.130848024+08:00" level=info msg="Loading containers: done." Sep 02 09:00:45 web-dev1 dockerd[30865]: time="2021-09-02T09:00:45.167723153+08:00" level=info msg="Docker daemon" commit=75249d8 graphdriver(s)=...n=20.10.8 Sep 02 09:00:45 web-dev1 dockerd[30865]: time="2021-09-02T09:00:45.167817837+08:00" level=info msg="Daemon has completed initialization" Sep 02 09:00:45 web-dev1 systemd[1]: Started Docker Application Container Engine. Sep 02 09:00:45 web-dev1 dockerd[30865]: time="2021-09-02T09:00:45.197823106+08:00" level=info msg="API listen on [::]:2375" Sep 02 09:00:45 web-dev1 dockerd[30865]: time="2021-09-02T09:00:45.202916732+08:00" level=info msg="API listen on /var/run/docker.sock" Hint: Some lines were ellipsized, use -l to show in full.
完毕!一点点试出来的,但我并没有弄清楚什么原理,对docker的部署问题还处于初级阶段。
docker开启remote-api 2375端口后,Failed to start Docker Application Container Engine,重启docker失败的问题解决