https://blog.csdn.net/li1325169021/article/details/90780627

安装需要的软件包

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2


设置stable镜像仓库(采用方式二)

  • 方式一(大坑)执行命令后报错,这种方式是错误的

[root@localhost ~]# yum-config-manager —add-repo https://download.docker.com/linux/centos/docker-ce.repo
1
报错:
1 [Errno 14] curl#35 - TCP connection reset by peer

2 [Errno 12] curl#35 - Timeout

  • 方式二

[root@localhost ~]# yum-config-manager —add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
1

更新yum软件包索引

[root@localhost ~]# yum makecache fast

安装DOCKER CE

[root@localhost ~]# yum -y install docker-ce
启动docker
[root@localhost ~]# systemctl start docker

查看docker版本

[root@localhost ~]# docker version
Client:
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 481bc77156
Built: Sat May 4 02:34:58 2019
OS/Arch: linux/amd64
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 18.09.6
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 02:02:43 2019
OS/Arch: linux/amd64
Experimental: false
[root@localhost ~]#

运行 hello-world

[root@localhost ~]# docker run hello-world

配置镜像加速

1)、获取阿里云镜像加速器参考:https://blog.csdn.net/li1325169021/article/details/90770119
[root@localhost ~]# vim /etc/docker/daemon.json
内容如下:

  1. {
  2. "registry-mirrors": ["http://hub-mirror.c.163.com"]
  3. }

[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker

查看docker服务的状态

systemctl status docker

设置docker开机启动服务

systemctl enable docker

12、卸载

[root@localhost ~]# systemctl stop docker
[root@localhost ~]# yum -y remove docker-ce
[root@localhost ~]# rm -rf /var/lib/docker