1.1. Docker Compose
1.1.1. 一、安装Docker Compose
curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose -version
1.1.2. 二、卸载Docker Compose
rm /usr/local/bin/docker-compose
1.1.3. 三、 使用docker compose编排nginx+springboot项目
- 创建docker-compose目录
mkdir ~/docker-compose
cd ~/docker-compose
- 编写 docker-compose.yml 文件
version: '3'
services:
nginx:
image: nginx
ports:
- 80:80
links:
- app
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
app:
image: app
expose:
- "8080"
- 创建./nginx/conf.d目录
mkdir -p ./nginx/conf.d
- 在./nginx/conf.d目录下 编写itheima.conf文件
server {
listen 80;
access_log off;
location / {
proxy_pass http://app:8080;
}
}
- 在~/docker-compose 目录下 使用docker-compose 启动容器
docker-compose up
- 测试访问
http://192.168.149.135/hello