一、Docker的安裝
Docker目前官方主要有兩個版本,一個是企業版(docker-ee),一個是社區版(docker-ce),我們這裏主要使用的是社區版。
1、安裝Docker CE
CentOS 7 基本倉庫是帶docker的,但是不是官方的版本,而且版本也比較低,我們推薦使用官方的yum源,而且對以後的升級也很方便。
1)安裝命令
wget -P /etc/yum.repos.d/ https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce
安裝成功後顯示
Installed:
docker-ce.x86_64 3:18.09.0-3.el7
Dependency Installed:
audit-libs-python.x86_64 0:2.8.4-4.el7 checkpolicy.x86_64 0:2.5-8.el7 container-selinux.noarch 2:2.74-1.el7 containerd.io.x86_64 0:1.2.0-3.el7
docker-ce-cli.x86_64 1:18.09.0-3.el7 libcgroup.x86_64 0:0.41-20.el7 libsemanage-python.x86_64 0:2.5-14.el7 libtool-ltdl.x86_64 0:2.4.2-22.el7_3
policycoreutils-python.x86_64 0:2.5-29.el7 python-IPy.noarch 0:0.75-6.el7 setools-libs.x86_64 0:3.3.8-4.el7
Dependency Updated:
audit.x86_64 0:2.8.4-4.el7 audit-libs.x86_64 0:2.8.4-4.el7 libselinux.x86_64 0:2.5-14.1.el7 libselinux-python.x86_64 0:2.5-14.1.el7
libselinux-utils.x86_64 0:2.5-14.1.el7 libsemanage.x86_64 0:2.5-14.el7 libsepol.x86_64 0:2.5-10.el7 policycoreutils.x86_64 0:2.5-29.el7
selinux-policy.noarch 0:3.13.1-229.el7_6.6 selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.6
Complete!
2)遇到的問題及解決
a)沒有安裝wget
-bash: wget: command not found
解決辦法:
yum -y install wget
b) 首先這個問題是因爲國內訪問不到docker官方鏡像的緣故,所以我們要使用 國內的源來訪問,之前我也試過163的源,但是一直解決不了,但是後來換了阿里源就成功解決了這個問題
GPG key retrieval failed: [Errno 14] curl#35 - "TCP connection reset by peer"
解決辦法:
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3)啓動並加入開機啓動
systemctl start docker
sudo systemctl enable docker
4)檢測是否安裝docker成功
輸入 docker version 指令看版本信息。出現如下圖,恭喜docker安裝成功!可以看到Client與Server的信息。
Client:
Version: 18.09.0
API version: 1.39
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:48:22 2018
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:19:08 2018
OS/Arch: linux/amd64
Experimental: false