1. 程式人生 > >docker學習之 安裝及啟動錯誤解決

docker學習之 安裝及啟動錯誤解決

docker學習

Linux centos7下安裝docker需要 linux 核心在 3.10.0 以上, 檢視核心的方法為:

# 檢視版本號
[[email protected] sysconfig]# uname -r
3.10.0-327.el7.x86_64

然後使用安裝命令:

[[email protected] ~]# yum install docker

途中會遇到輸入 y/n ,直接輸入y繼續就行了,直到出現 ‘Complete!’ 表示安裝完成。

使用 docker -v 檢視docker版本:

[[email protected]
~]# docker -v Docker version 1.13.1, build 07f3374/1.13.1

出現版本號則表示安裝成功,可以啟動docker了,啟動命令為:

[[email protected] /]# 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.

使用上面提供的命令檢視狀態:

[[email protected] ~]# 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)

解決方法

[[email protected] ~]# cd /etc/sysconfig
[[email protected] ~]# 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 就可以正常啟動了!