我尝试将 Docker 安装到 Ubuntu 18.04。
我使用这个指南: https://docs.docker.com/install/linux/docker-ce/ubuntu/
第一次,我通过了所有步骤,但在最后尝试安装 docker-ce 时出现错误:
# apt-get install docker-ce docker-ce-cli containerd.io
然后,安装就出错了。之后,我尝试从第一步再次安装 docker:
$ sudo apt-get remove docker docker-engine docker.io containerd runc
并得到这个:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'docker-engine' is not installed, so not removed
Package 'containerd' is not installed, so not removed
Package 'docker' is not installed, so not removed
Package 'docker.io' is not installed, so not removed
Package 'runc' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 58 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up docker-ce (5:18.09.5~3-0~ubuntu-bionic) ...
update-alternatives: warning: forcing reinstallation of alternative /usr/bin/dockerd-ce because link group dockerd is broken
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Fri 2019-04-12 13:52:26 MSK; 11ms ago
Docs: https://docs.docker.com
Process: 1884 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 1884 (code=exited, status=1/FAILURE)
Apr 12 13:52:26 n0ykp.vps.myjino.ru systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Apr 12 13:52:26 n0ykp.vps.myjino.ru systemd[1]: docker.service: Failed with result 'exit-code'.
Apr 12 13:52:26 n0ykp.vps.myjino.ru systemd[1]: Failed to start Docker Application Container Engine.
dpkg: error processing package docker-ce (--configure):
installed docker-ce package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
docker-ce
E: Sub-process /usr/bin/dpkg returned an error code (1)
请帮助我解决问题并安装docker。
UPD。之后
apt purge docker docker-ce docker-engine docker.io containerd runc
:
root@ovz1:~# dpkg -i /home/xpendence/downloads/docker-ce_18.09.5_3-0_ubuntu-bionic_amd64.deb
Selecting previously unselected package docker-ce.
(Reading database ... 33991 files and directories currently installed.)
Preparing to unpack .../docker-ce_18.09.5_3-0_ubuntu-bionic_amd64.deb ...
Unpacking docker-ce (5:18.09.5~3-0~ubuntu-bionic) ...
Setting up docker-ce (5:18.09.5~3-0~ubuntu-bionic) ...
update-alternatives: using /usr/bin/dockerd-ce to provide /usr/bin/dockerd (dockerd) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xe" for details.
invoke-rc.d: initscript docker, action "start" failed.
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Fri 2019-04-12 15:27:23 MSK; 11ms ago
Docs: https://docs.docker.com
Process: 3938 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 3938 (code=exited, status=1/FAILURE)
Apr 12 15:27:23 n0ykp.vps.myjino.ru systemd[1]: docker.service: Failed with result 'exit-code'.
Apr 12 15:27:23 n0ykp.vps.myjino.ru systemd[1]: Failed to start Docker Application Container Engine.
dpkg: error processing package docker-ce (--install):
installed docker-ce package post-installation script subprocess returned error exit status 1
Processing triggers for systemd (237-3ubuntu10.11) ...
Errors were encountered while processing:
docker-ce
答案1
我遇到了类似的问题。Ubuntu 从 18.04.4 升级到 20.04.2 后,docker 无法启动,并且在尝试安装、删除、清除、修复时出错。
$ sudo apt-get purge -y docker-ce
...
1 not fully installed or removed.
...
Removing docker-ce (5:20.10.4~3-0~ubuntu-bionic) ...
Job for docker.service canceled.
invoke-rc.d: initscript docker, action "stop" failed.
dpkg: error processing package docker-ce (--remove):
installed docker-ce package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
dpkg: error while cleaning up:
installed docker-ce package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
docker-ce
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)
有两个可以安装的 docker 软件包:来自 Debian/Ubuntu 的 docker.io 和来自 docker.com 的 docker-ce。这邮政讨论差异。我都安装了
dpkg -l | grep -i docker
看起来它被卡住了,containerd
无法启动。您可以在/var/log/syslog
尝试了很多方法,但都没有用
$ sudo dpkg --configure -a
$ sudo systemctl list-jobs
$ sudo systemctl disable docker.service
$ sudo systemctl disable containerd.service
$ sudo systemctl stop containerd.service
...
删除文件夹,卸载所有 docker 软件包并重新安装 docker.io 有效
$ sudo rm -rf /var/lib/containerd/
$ sudo rm -rf /var/lib/docker/
$ sudo apt-get purge -y docker-ce docker-ce-cli docker.io containerd.io
$ sudo apt-get install docker.io