我已经根据资源安装了 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
首先,验证文件
/lib/systemd/system/docker.service
确实存在;如果没有,则之前的安装步骤失败 - 或者自编写教程以来服务的名称已更改。然后,运行
systemctl daemon-reload
以使 systemd 重新加载任何新的单元文件。如果systemctl status docker
在此之后工作,您可能会提交有关错误.deb
打包的错误报告 - 包应该在安装时自动完成。在评论中发现错误消息是:
systemctl
这表明命令和systemd
守护程序之间的通信存在某种问题。systemctl status
一般都有效吗?您是否使用其他一些初始化系统而不是 Debian 9 默认系统
systemd
?您安装的 Docker 软件包假定systemd
已使用。systemd-sysv
安装包了吗?替代解决方案。
当我在 debian 上安装 docker 时,我使用
apt
. 我首先必须将存储库添加到源中。但在那之后我只是做了一个 apt-get 更新和一个 apt-get 安装。这要容易得多。