无法在 Ubuntu 中安装 Docker(路透码)



我正在尝试使用以下命令sudo apt install docker.io在ubuntu 18.04中安装docker。问题是,在一些事情完成后,它实际上开始安装docker,我得到了以下错误:

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; disabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Wed 2019-11-06 15:24:39 EST; 4ms ago
Docs: https://docs.docker.com
Process: 6303 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 6303 (code=exited, status=1/FAILURE)

我尝试了systemctl status docker.servicejournalctl -xe,但无法解决问题,因为我是linux 的新手

编辑

systemctl status docker.service output:

Loaded: loaded (/lib/systemd/system/docker.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2019-11-07 09:18:38 EST; 6s ago
Docs: https://docs.docker.com
Process: 2819 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 2819 (code=exited, status=1/FAILURE)
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: docker.service: Scheduled restart job, restart counter is at 4.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: Stopped Docker Application Container Engine.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: docker.service: Start request repeated too quickly.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: docker.service: Failed with result 'exit-code'.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: Failed to start Docker Application Container Engine.

journalctl -xe

-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit docker.socket has finished shutting down.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: Stopping Docker Socket for the API.
-- Subject: Unit docker.socket has begun shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit docker.socket has begun shutting down.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: Starting Docker Socket for the API.
-- Subject: Unit docker.socket has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit docker.socket has begun starting up.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: Listening on Docker Socket for the API.
-- Subject: Unit docker.socket has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit docker.socket has finished starting up.
-- 
-- The start-up result is RESULT.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: docker.service: Start request repeated too quickly.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: docker.service: Failed with result 'exit-code'.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit docker.service has failed.
-- 
-- The result is RESULT.
Nov 07 09:18:38 alejandro-ThinkPad-E480 systemd[1]: docker.socket: Failed with result 'service-start-limit-hit'.
Nov 07 09:19:26 alejandro-ThinkPad-E480 pkexec[2910]: pam_unix(polkit-1:session): session opened for user root by (uid=1000)
Nov 07 09:19:26 alejandro-ThinkPad-E480 pkexec[2910]: alejandro: Executing command [USER=root] [TTY=unknown] [CWD=/home/alejandro] [COMMAND=/usr/lib/u

我曾尝试在Ubuntu上安装Docker,但遇到了如下错误:

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 Wed 2020-01-08 09:41:04 KST; 11ms ago
Docs: https://docs.docker.com
Process: 3644 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
Main PID: 3644 (code=exited, status=1/FAILURE)
dpkg: error processing package docker-ce (--configure):
installed docker-ce package post-installation script subprocess returned error exit status 1

如果用户不在"adm"组中,则"journalctl-xe"不会显示所有消息。

"sudojournalctl-xe"显示以下消息:

1월 08 09:41:03 kdndemo-desktop groupadd[3451]: group added to /etc/group: name=docker, GID=999
1월 08 09:41:03 kdndemo-desktop groupadd[3451]: group added to /etc/gshadow: name=docker
1월 08 09:41:03 kdndemo-desktop groupadd[3451]: new group: name=docker, GID=999
1월 08 09:41:03 kdndemo-desktop systemd[1]: Reloading.
1월 08 09:41:03 kdndemo-desktop systemd[1]: Starting Daily apt download activities...
1월 08 09:41:03 kdndemo-desktop systemd[1]: Started Daily apt download activities.
1월 08 09:41:03 kdndemo-desktop systemd[1]: Reloading.
1월 08 09:41:04 kdndemo-desktop systemd[1]: Reloading.
1월 08 09:41:04 kdndemo-desktop systemd[1]: Reloading.
1월 08 09:41:04 kdndemo-desktop systemd[1]: Starting Docker Application Container Engine...
1월 08 09:41:04 kdndemo-desktop dockerd[3644]: time="2020-01-08T09:41:04.683235561+09:00" level=info msg="Starting up"
1월 08 09:41:04 kdndemo-desktop dockerd[3644]: failed to load listeners: no sockets found via socket activation: make sure the service was started by systemd
1월 08 09:41:04 kdndemo-desktop systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
1월 08 09:41:04 kdndemo-desktop systemd[1]: docker.service: Failed with result 'exit-code'.
1월 08 09:41:04 kdndemo-desktop systemd[1]: Failed to start Docker Application Container Engine.

在我的情况下,我通过在/etc/group中的帐户中添加一个组来解决这个问题。

sudo:x:27:nini

试试这个方法:

sudo apt-get update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
sudo apt install docker-ce

安装docker撰写

sudo apt-get install docker-compose

如果你有非0结束返回错误,那么首先停止docker服务

systemctl stop docker

并在安装compose后重新启动

systemctl start docker

检查docker是否正在运行

sudo systemctl status docker
sudo docker run hello-world

最新更新