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 就可以正常啓動了!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章