近期小编在启动docker服务之后遇到一个报错:“Job for docker.service failed because a configured resource limit was exceeded. See "systemctl status docker.service" and "journalctl -xe" for details”
[root@200250229-node1 ~]#systemctl daemon-reload
[root@200250229-node1 ~]# systemctl start docker
Job for docker.service failed because start of the service was attempted too often. Status docker.service" and "journalctl -xe" for details.
To force a start use "systemctl reset-failed docker.service" followed by "systemctl svice" again.
[root@200250229-node1 docker]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: d
Drop-In: /usr/lib/systemd/system/docker.service.d
└─flannel.conf
Active: failed (Result: start-limit) since Sat 2022-04-16 19:58:25 CST; 2min 32s a
Docs: https://docs.docker.com
Apr 16 19:58:25 200250229-node1 systemd[1]: start request repeated too quickly for do
Apr 16 19:58:25 200250229-node1 systemd[1]: Failed to start Docker Application Contai
Apr 16 19:58:25 200250229-node1 systemd[1]: Unit docker.service entered failed state.
Apr 16 19:58:25 200250229-node1 systemd[1]: docker.service failed.
Apr 16 19:58:38 200250229-node1 systemd[1]: start request repeated too quickly for do
Apr 16 19:58:38 200250229-node1 systemd[1]: Failed to start Docker Application Contai
Apr 16 19:58:38 200250229-node1 systemd[1]: docker.service failed.
Apr 16 19:59:11 200250229-node1 systemd[1]: start request repeated too quickly for do
Apr 16 19:59:11 200250229-node1 systemd[1]: Failed to start Docker Application Contai
Apr 16 19:59:11 200250229-node1 systemd[1]: docker.service failed
真时令人百思不得解。这句话的意思是:docker的工作。服务失败,因为超出了配置的资源限制。由此可知这必然是配置文件的错误,于是我在网上找了一些答案但是效果甚微:大部分都是说修改配置文件后缀:
[root@200250229-node1 ~]# cd /etc/docker
[root@200250229-node1 docker]# ll
total 4
-rw------- 1 root root 244 Mar 12 00:15 key.json
[root@200250229-node1 docker]# mv key.json key.conf
[root@200250229-node1 docker]# ll
total 4
-rw------- 1 root root 244 Mar 12 00:15 key.conf
//再次尝试
[root@200250229-node1 ~]#systemctl daemon-reload
[root@200250229-node1 ~]# systemctl start docker
Job for docker.service failed because start of the service was attempted too often. Status docker.service" and "journalctl -xe" for details.
To force a start use "systemctl reset-failed docker.service" followed by "systemctl svice" again.
看来不行
于是我试了一下肯本没有用!
就在这时我想到了,上一次做了flannel网络配置实验,并修改了docker的配置文件/usr/lib/systemd/system/docker.service
而我们只需要把修改的部分去掉就可以了;
去掉之前:
去掉之后:
[root@200250229-node1 ~]# vi /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.service
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
#EnvironmentFile=/run/docker_opts.env <===这一行注释掉
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock insecure-registry 172.22.29.100:5000//这一行删掉-H前面的$DOCKER_OPTS就可以了
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
再来试一下,重启docker服务:
[root@200250229-node1 ~]# systemctl daemon-reload
[root@200250229-node1 ~]# systemctl restart docker
[root@200250229-node1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest 2fb6fc2d97e1 5 weeks ago 1.24MB
172.22.29.100:5000/busybox latest 829374d342ae 6 weeks ago 1.24MB
可以看见,成功启动了!看来就是这个问题