0

我想安装 docker-ce,但它无法启动

我以这种方式安装 docker-ce:

sudo yum install docker-ce

我的系统类型:

Linux version 3.10.107-1-tlinux2_kvm_guest-0046 (root@TENCENT64.site) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ) #1 SMP Wed Dec 27 10:57:04 CST 2017

码头工人版本:

docker version
Client:
 Version:           18.09.7
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        2d0083d
 Built:             Thu Jun 27 17:56:06 2019
 OS/Arch:           linux/amd64
 Experimental:      false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

错误信息详情:

systemctl status docker.service
* docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/docker.service.d
           `-override.conf
   Active: failed (Result: start-limit) since Wed 2019-07-31 10:12:15 CST; 921ms ago
     Docs: https://docs.docker.com
  Process: 15961 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=1/FAILURE)
 Main PID: 15961 (code=exited, status=1/FAILURE)

Jul 31 10:12:13 TENCENT64.site systemd[1]: Failed to start Docker Application Container Engine.
Jul 31 10:12:13 TENCENT64.site systemd[1]: Unit docker.service entered failed state.
Jul 31 10:12:13 TENCENT64.site systemd[1]: docker.service failed.
Jul 31 10:12:15 TENCENT64.site systemd[1]: docker.service holdoff time over, scheduling restart.
Jul 31 10:12:15 TENCENT64.site systemd[1]: Stopped Docker Application Container Engine.
Jul 31 10:12:15 TENCENT64.site systemd[1]: start request repeated too quickly for docker.service
Jul 31 10:12:15 TENCENT64.site systemd[1]: Failed to start Docker Application Container Engine.
Jul 31 10:12:15 TENCENT64.site systemd[1]: Unit docker.service entered failed state.
Jul 31 10:12:15 TENCENT64.site systemd[1]: docker.service failed.
journalctl -xe
Jul 31 10:12:13 TENCENT64.site systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has failed.
-- 
-- The result is failed.
Jul 31 10:12:13 TENCENT64.site systemd[1]: Unit docker.service entered failed state.
Jul 31 10:12:13 TENCENT64.site systemd[1]: docker.service failed.
Jul 31 10:12:15 TENCENT64.site systemd[1]: docker.service holdoff time over, scheduling restart.
Jul 31 10:12:15 TENCENT64.site systemd[1]: Stopped Docker Application Container Engine.
-- Subject: Unit docker.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has finished shutting down.
Jul 31 10:12:15 TENCENT64.site systemd[1]: Closed Docker Socket for the API.
-- Subject: Unit docker.socket has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.socket has finished shutting down.
Jul 31 10:12:15 TENCENT64.site systemd[1]: Stopping Docker Socket for the API.
-- Subject: Unit docker.socket has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.socket has begun shutting down.
Jul 31 10:12:15 TENCENT64.site systemd[1]: Starting Docker Socket for the API.
-- Subject: Unit docker.socket has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.socket has begun starting up.
Jul 31 10:12:15 TENCENT64.site systemd[1]: Listening on Docker Socket for the API.
-- Subject: Unit docker.socket has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.socket has finished starting up.
-- 
-- The start-up result is done.
Jul 31 10:12:15 TENCENT64.site systemd[1]: start request repeated too quickly for docker.service
Jul 31 10:12:15 TENCENT64.site systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit docker.service has failed.
-- 
-- The result is failed.
Jul 31 10:12:15 TENCENT64.site systemd[1]: Unit docker.service entered failed state.
Jul 31 10:12:15 TENCENT64.site systemd[1]: docker.service failed.

我的 daemon.json(/etc/docker/daemon.json) 不存在,当我创建一个内容为 '{}' 的 daemon.json 时,也报错

我尝试了一些方法:

  1. 清除 /var/lib/docker
  2. 重新安装 docker-ce

docker的老版本docker和docker-io正常,但是没有ip和端口映射,所以我现在用docker-ce。

如何解决这个问题?

4

1 回答 1

0

Docker 可以通过两种不同的方法启动:

  1. Via systemctl,这是推荐的方式
  2. 直接通过 docker daemon bin :dockerd这不是推荐的方式

但是,当您直接启动 docker 守护程序时(即不使用systemctl),systemctl无法知道守护程序的当前状态。

所以我的猜测是,在安装之后,docker 守护进程以某种方式部分启动并失败了。
要检查是否是这种情况,只需运行:

sudo ps -aux | grep dockerd

然后杀死所有附加到 docker 守护进程的进程。
完成后,您应该可以通过 systemctl 直接启动 docker。

于 2019-07-31T09:13:57.057 回答