美文网首页
docker后,启动时报错

docker后,启动时报错

作者: kribeel | 来源:发表于2018-01-17 16:01 被阅读0次

yum安装docker后,启动时报错,systemctl status docker信息如下

[root@localhost ~]# systemctl start docker
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
[root@localhost ~]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/etc/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since 三 2018-01-17 15:10:45 CST; 13s ago
     Docs: https://docs.docker.com
  Process: 2800 ExecStart=/usr/bin/docker daemon --registry-mirror=https://*prk4fun.mirror.aliyuncs.com --registry-mirror=https://*prk4fun.mirror.aliyuncs.com (code=exited, status=125)
 Main PID: 2800 (code=exited, status=125)

1月 17 15:10:45 localhost.localdomain docker[2800]: tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
1月 17 15:10:45 localhost.localdomain docker[2800]: top         Display the running processes of a container
1月 17 15:10:45 localhost.localdomain docker[2800]: unpause     Unpause all processes within one or more containers
1月 17 15:10:45 localhost.localdomain docker[2800]: update      Update configuration of one or more containers
1月 17 15:10:45 localhost.localdomain docker[2800]: version     Show the Docker version information
1月 17 15:10:45 localhost.localdomain docker[2800]: wait        Block until one or more containers stop, then print their exit codes
1月 17 15:10:45 localhost.localdomain docker[2800]: Run 'docker COMMAND --help' for more information on a command.
1月 17 15:10:45 localhost.localdomain systemd[1]: Failed to start Docker Application Container Engine.
1月 17 15:10:45 localhost.localdomain systemd[1]: Unit docker.service entered failed state.
1月 17 15:10:45 localhost.localdomain systemd[1]: docker.service failed.


  • 很奇怪的是这一行
Process: 2800 ExecStart=/usr/bin/docker daemon --registry-mirror=https://*prk4fun.mirror.aliyuncs.com 
--registry-mirror=https://*prk4fun.mirror.aliyuncs.com (code=exited, status=125)

两个--registry-mirror,知道是什么鬼。这个镜像的地址是阿里云加速的地址,回想安装的步骤。

使用脚本自动安装
在测试或开发环境中 Docker 官方为了简化安装流程,提供了一套便捷的安装脚本,CentOS 系统上可以使用这套脚本安装:

$ curl -fsSL get.docker.com -o get-docker.sh
$ sudo sh get-docker.sh --mirror Aliyun

以为是加了Aliyun的问题,重新卸载,再安装问题依旧。

  • 找到/etc/systemd/system/docker.service文件,查看文件内容,发现文件内容被修改过

原来的ExecStart被注释掉了,加了daemon,配置上了aliyun的加速器地址

# 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
ExecStart=/usr/bin/docker daemon --registry-mirror=https://*prk4fun.mirror.aliyuncs.com 
--registry-mirror=https://*prk4fun.mirror.aliyuncs.com
  • 修改一下这个文件,把daemon这一行注释掉,放开原来的注释。docker启动正常。
[root@localhost docker]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: active (running) since 三 2018-01-17 15:31:34 CST; 25min ago
     Docs: https://docs.docker.com
 Main PID: 3275 (dockerd)
   Memory: 45.3M
   CGroup: /system.slice/docker.service
           ├─3275 /usr/bin/dockerd
           └─3289 docker-containerd --config /var/run/docker/containerd/containerd.toml
  • 加速器配置

针对Docker客户端版本大于1.10.0的用户
您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器:

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://*******.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

相关文章

网友评论

      本文标题:docker后,启动时报错

      本文链接:https://www.haomeiwen.com/subject/euruoxtx.html