如何解决docker.service:服务缺少 ExecStart= 和 ExecStop= 设置拒绝
我的虚拟机因为内存不足而崩溃。重新启动机器后,docker 没有运行:
systemctl status docker
● docker.service
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
Dec 19 08:18:21 my-vm-single-instance systemd[1]: [/lib/systemd/system/docker.service:1] Assignment outside of section. Ignoring.
Dec 19 08:18:21 my-vm-single-instance systemd[1]: docker.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
我使用官方文档安装了 docker:https://docs.docker.com/engine/install/debian/
VM 正在运行:
Debian GNU/Linux 9 (stretch)
Docker version 19.03.14,build 5eb3275d40
docker-compose version 1.25.4,build 8d51620a
我使用 docker 重新启动并运行
dockerd
但是我想通过 systemctl 让它再次运行。
/lib/systemd/system/docker.service
的内容是:
Environment="GOOGLE_APPLICATION_CREDENTIALS=/etc/docker/key.json"
任何想法如何解决这个问题?
解决方法
如果 docker.service
只包含一行,因为它提到的是假的。
正如它所说
docker.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.
至少缺少执行脚本。
这是一个示例服务文件:
[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
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
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.
# Both the old,and new location are accepted by systemd 229 and up,so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3
# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old,and new name are accepted by systemd 230 and up,so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Comment TasksMax if your systemd version does not support it.
# Only systemd 226 and above support this option.
TasksMax=infinity
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process,not all processes in the cgroup
KillMode=process
OOMScoreAdjust=-500
[Install]
WantedBy=multi-user.target
这是我的默认服务文件。安装后我从未修改过。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。