最近使用docker,在虚拟机上通过yum安装了docker,通过docker-v看到版本信息是1.13.但是后续在启动服务的时候,报错。

下面是转载别人的文章。原文地址是:https://blog.csdn.net/R_s_x/article/details/80169738

前言

    在k8s的系列学习中,需要使用docker的环境,在安装docker的过程中遇到的一些问题在这里分享一下。通过查找资料发现之前的文章解决不了,后来让华玫妹妹给我指点了一下,思路是没问题的,但是自己的操作太生疏了,修改文件简单地操作都是个问题,需要不断地练习啊!

安装步骤


[root@localhost ~]# yum update
[root@localhost ~]# yum install docker

[root@localhost ~]# service docker start

Redirecting to /bin/systemctl start docker.service
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.service

● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since 日 2018-04-08 13:00:31 CST; 11min ago
Docs: http://docs.docker.com
Process: 44128 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=systemd --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
 Main PID: 44128 (code=exited, status=1/FAILURE)
 408 13:00:30 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
 //后面还有具体的就不一一列举了

尝试一

参考:解决方案

# yum remove docker
# yum remove docker-selinux

# vi /etc/yum.repos.d/docker.repo

//要打开docker.repo,提示我【new file】

    到这里就进行不下去了,于是就换了另外的方法。

尝试二

[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# ls

[root@localhost system]# vi docker.service

[root@localhost system]# systemctl daemon-reload

[root@localhost system]# systemctl restart docker

[root@localhost system]# systemctl status docker.service

参考:修改配置文件docker.service

    在修改docker.service的时候由于操作不太熟悉,我直接打开文件修改的。只将ExecStart内容都修改了。(小白福利)效果如下:

[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target rhel-push-plugin.socket registries.service
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer

[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/run/containers/registries.conf
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd --insecure-registry=sz-pg-oam-docker-hub-001.tendcloud.com -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
MountFlags=slave
KillMode=process

[Install]
WantedBy=multi-user.target

    现在docker服务可以启动了。这里要特别注意的是:

查看文件系统 /etc/docker/daemon.json 有没有这个文件,没有测创建它包括二级目录 docker

在daemon.json文件中输入以下内容:

{ "storage-driver": "devicemapper" }或者是:{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}    特别提示:如果json格式不正确,获取缺少标点符号等,将会导致系统启动不了。我在这里吃了一天的亏!!!!!!!!
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐