在CentOS 7上安装Docker
-
更新系统
sudo yum update
-
安装必要的软件包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
-
添加Docker仓库
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
-
安装Docker引擎
sudo yum install docker-ce
-
启动Docker服务
sudo systemctl start docker
-
设置Docker开机自启动
sudo systemctl enable docker
-
验证安装是否成功
sudo docker --version
Docker Compose安装步骤
1.下载安装
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
2.给执行权限
sudo chmod +x /usr/local/bin/docker-compose
3.创建链接
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
4.查看docker-compose版本
docker-compose --version
5.创建docker-compose.yml文件
vim docker-compose.yml
6.使用方法
docker-compose up -d