curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

============
1、删除旧版
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine

2、用稳定版的更新源
yum install -y yum-utils
yum-config-manager \
–add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

3、安裝Docker引擎
yum install docker-ce docker-ce-cli containerd.io

4、启动Docker
systemctl enable docker
systemctl start docker

5、测试
docker run hello-world

6、升级docker引擎
yum -y upgrade

7、删除docker引擎
yum remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
rm -rf /var/lib/containerd

BTW:安装特殊版本的docker引擎
# 从高到低列出版本
yum list docker-ce –showduplicates | sort -r
# yum install docker-ce-18.09.1 docker-ce-cli-18.09.1 containerd.io
yum install docker-ce- docker-ce-cli- containerd.io
———-
2、拉取CentOS镜像
docker run -d -p 2222:22 –name CentOS-Docker ilemonrain/centos-sshd

参数说明
-d:以Daemon(后台)模式启动镜像
-p 2222:22:暴露宿主机的2222端口,映射到容器内部的22端口 (SSH)
–name CentOS-Docker:容器名称
ilemonrain/centos-sshd:镜像名称

===========
安裝docker-compose
# 安装
curl -L “https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-compose
# 付权
chmod +x /usr/local/bin/docker-compose
# 建立快捷方式,以便环境变量加载
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# 测试安装成功
docker-compose –version

PS:https://docs.docker.com/engine/install/centos/