//环境部署所有主机安装docker环境(内容为docker基础)
yum install docker-ce -y
//下载compose
curl -L https://github.com/docker/compose/releases/download/1.21.1/docker-compose- uname -s'- uname -mi -o /usr/local/bin/docker- compose
mkdir compose_ nginx
cp -p docker-compose /usr/local/bin/
chmod +x /usr/local/bin/docker-compose
由于下载很慢,所以我就直接创建了一个目录把之前下载好的包放进去
vim /root/compose_nginx/docker-compose.yml
version: '3'
services:
nginx:
hostname: nginx
build:
context: ./nginx
dockerfile: Dockerfile
ports:
- 1001:80
- 1002:443
networks:
- cluster
volumes:
- ./wwwroot:/usr/local/nginx/html
networks:
cluster:
放入相关文件
mkdir nginx
mkdir wwwroot
echo "this is nginx" > wwwroot/index.html
cp /opt/nginx/* /root/compose_nginx/nginx/ //把之前做过的nginx配置文件复制过来
tree ./
docker-compose -f docker-compose.yml up -d