sudo yum install -y yum-utils
# 下面这两个视具体情况执行
# sudo yum install -y device-mapper-persistent-data lvm2
# sudo yum-config-manager --enable rhel-7-server-extras-rpms
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum install -y http://mirror.centos.org/centos/7/extras/x86_64/Packages/container-selinux-2.107-1.el7_6.noarch.rpm
sudo yum install docker-ce-18.06.3.ce-3.el7.x86_64
# 如果需要选择版本可以输入如下命令查看版本
# yum list docker-ce --showduplicates|sort -r
# yum install docker-ce-<version>-<release>
sudo systemctl start docker
sudo systemctl enable docker
docker -v
#Test your Docker CE installation:
sudo docker run hello-world
sudo pip install docker-compose
如果pip也没有,那么先按照如下执行安装pip并更新python包
# install python-pip
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum install ./epel-release-latest-7.noarch.rpm
sudo yum install -y python-pip
# upgrade your Python packages:
sudo yum upgrade python*
参考文章: