依据下面的步骤命令一步步操作,即可安装docker-compose环境到服务器
yum install -y yum-utils
# 阿里云地址(国内地址,相对更快)
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install -y docker-ce docker-ce-cli containerd.io
docker version # 查看Docker版本信息
systemctl start docker # 启动 docker 服务:
systemctl stop docker # 停止 docker 服务:
systemctl status docker # 查看 docker 服务状态
systemctl restart docker # 重启 docker 服务
systemctl enable docker # 开机启动 docker
容器加速
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://eb0wjrgc.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 因为Docker Compose存放在GitHub,可能不太稳定。可以通过DaoCloud加速下载
curl -L https://get.daocloud.io/docker/compose/releases/download/1.26.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# 上面两个链接都失效了
curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# 将可执行权限应用于该二进制文件
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
# 卸载 rm /usr/local/bin/docker-compose
docker images
docker ps
docker stop id
docker start id
docker rmi images
docker rm container