![Docker CE 未在 Debian 9 上注册为服务](https://linux22.com/image/142018/Docker%20CE%20%E6%9C%AA%E5%9C%A8%20Debian%209%20%E4%B8%8A%E6%B3%A8%E5%86%8C%E4%B8%BA%E6%9C%8D%E5%8A%A1.png)
我根据资源安装了Docker社区版:https://linuxize.com/post/how-to-install-and-use-docker-on-debian-9/
但是,当我到达步骤 5(systemctl status docker)时,我收到以下错误消息而不是服务状态:
root@srv-012:/etc/systemd# systemctl start docker
Failed to start docker.service: Unknown unit: docker.service
See system logs and 'systemctl status docker.service' for details.
所有命令均以 root 身份运行。我怎样才能解决这个问题?
编辑:
The file `/lib/systemd/system/docker.service` is created correctly, here is the contents:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service
Wants=network-online.target
[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 unix://
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 supports 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
[Install]
WantedBy=multi-user.target
答案1
首先,验证文件/lib/systemd/system/docker.service
是否确实存在;如果没有,则先前的安装步骤失败 - 或者自教程编写以来服务名称已更改。
然后,运行systemctl daemon-reload
以使 systemd 重新加载任何新的单元文件。如果systemctl status docker
在此之后工作正常,您可以提交有关不良打包的错误报告.deb
- 软件包应该在安装时自动完成此操作。
在评论中发现错误消息是:
Failed to get properties: No such interface ''
systemctl
这表明命令和守护程序之间的通信存在某种问题systemd
。
systemctl status
一般情况下有用吗?
您是否使用其他 init 系统而不是 Debian 9 默认系统systemd
?您安装的 Docker 软件包假定systemd
已被使用。软件包安装了吗systemd-sysv
?
答案2
替代解决方案。
当我在 debian 上安装 docker 时,我使用apt
.我首先必须将存储库添加到源中。但之后我只做了一个 apt-get 更新和 apt-get 安装。这要容易得多。