1、安装条件
Linux 内核:官方建议 3.10 及以上
查看当前的内核版本
[root@localhost software]# uname -r
3.10.0-1062.el7.x86_64
安装参照官网:https://docs.docker.com/engine/install/centos/
Docker分为CE(社区版)和 EE(企业版)两大版本
这里安装社区版
2、如果之前安装过,可以执行下面命令卸载
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
3、安装需要的软件包
# 工具
[root@localhost software]# yum install -y yum-utils device-mapper-persistent-data lvm2
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink
# 配置yum源
[root@localhost software]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
4、查看可以安装的版本
[root@localhost software]# yum list docker-ce --showduplicates | sort -r
* updates: mirrors.jlu.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
* extras: ftp.sjtu.edu.cn
* epel: mirror-hnd.misakamikoto.network
docker-ce.x86_64 3:24.0.0-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.6-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.5-1.el7 docker-ce-stable
docker-ce.x86_64 3:23.0.4-1.el7 docker-ce-stable
.
.
.
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.3.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.2.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
安装: yum install docker-ce-版本号
[root@localhost software]# yum install docker-ce-18.03.1.ce
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
.
.
.
Installed:
docker-ce.x86_64 0:18.03.1.ce-1.el7.centos
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 pigz.x86_64 0:2.3.4-1.el7
Complete!
成功查看版本
[root@localhost software]# docker version
Client:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:20:16 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:23:58 2018
OS/Arch: linux/amd64
Experimental: false
5、启动、并且设置开机启动
systemctl start docker
systemctl enable docker