1.卸载旧版本Docker
sudo yum remove docker docker-common docker-selinux docker-engine
2.执行以下命令安装依赖包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
3.鉴于国内网络问题,强烈建议使用国内源执行下面的命令添加 yum 软件源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4.安装Docker CE
sudo yum -y install docker-ce
5.设置开机启动 Docker CE
sudo systemctl enable docker sudo systemctl start docker
6.鉴于国内网络问题,后续拉取 Docker 镜像十分缓慢,强烈建议安装 Docker 之后配置 国内镜像加速
sudo vi /etc/docker/daemon.json { "registry-mirrors": ["https://registry.docker-cn.com"] }
7.重启生效
sudo systemctl daemon-reload sudo systemctl restart docker
8.安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose docker-compose --version
Atas ialah kandungan terperinci 安装docker和docker-compose. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!