docker学习之 安装及启动错误解决

docker学习

Linux centos7下安装docker需要 linux 内核在 3.10.0 以上, 查看内核的方法为:

# 查看版本号
[root@localhost sysconfig]# uname -r
3.10.0-327.el7.x86_64

然后使用安装命令:

[root@localhost ~]# yum install docker

途中会遇到输入 y/n ,直接输入y继续就行了,直到出现 ‘Complete!’ 表示安装完成。

使用 docker -v 查看docker版本:

[root@localhost ~]# docker -v
Docker version 1.13.1, build 07f3374/1.13.1

出现版本号则表示安装成功,可以启动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.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 Sat 2018-12-15 02:57:20 EST; 38s ago
     Docs: http://docs.docker.com
  Process: 4955 ExecStart=/usr/bin/dockerd-current --add-runtime docker-runc=/usr/libexec/do
cker/docker-runc-current --default-runtime=docker-runc --exec-opt native.cgroupdriver=system
d --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --init-path=/usr/libexec/do
cker/docker-init-current --seccomp-profile=/etc/docker/seccomp.json $OPTIONS $DOCKER_STORAGE
_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIE
S (code=exited, status=1/FAILURE)

解决方法

[root@localhost ~]# cd /etc/sysconfig
[root@localhost ~]# vi docker

# /etc/sysconfig/docker

# Modify these options if you want to change the way the docker daemon runs
# 将下面的OPTIONS选项的 --selinux-enabled 改为 --selinux-enabled=false就可以了
OPTIONS ='--selinux-enabled=false --log-driver=journald --signature-verification=false'
if [ -z "${DOCKER_CERT_PATH}" ]; then
    DOCKER_CERT_PATH=/etc/docker
fi

# Do not add registries in this file anymore. Use /etc/containers/registries.conf
# instead. For more information reference the registries.conf(5) man page.

# Location used for temporary files, such as those created by
# docker load and build operations. Default is /var/lib/docker/tmp
# Can be overriden by setting the following environment variable.
# DOCKER_TMPDIR=/var/tmp

# Controls the /etc/cron.daily/docker-logrotate cron job status.
# To disable, uncomment the line below.
# LOGROTATE=false

# docker-latest daemon can be used by starting the docker-latest unitfile.
# To use docker-latest client, uncomment below lines
"docker" 26L, 1101C

修改完以后 :wq,保存退出,使用 systemctl restart docker 就可以正常启动了!

猜你喜欢

转载自blog.csdn.net/weixin_40203134/article/details/85015382
今日推荐