Docker learning Part-07 (Docker Compose service orchestration)

Docker Compose

First, install Docker Compose

# Compose目前已经完全支持Linux、Mac OS和Windows,在我们安装Compose之前,需要先安装Docker。下面我 们以编译好的二进制包方式安装在Linux系统中。 
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

Second, uninstall Docker Compose

# 二进制包方式安装的,删除二进制文件即可
rm /usr/local/bin/docker-compose

Third, the use docker compose choreography nginx + springboot project

  1. Create a docker-compose directory
mkdir ~/docker-compose
cd ~/docker-compose
  1. Write docker-compose.yml file
version: '3'
services:
  nginx:
   image: nginx
   ports:
    - 80:80
   links:
    - app
   volumes:
    - ./nginx/conf.d:/etc/nginx/conf.d
  app:
    image: app
    expose:
      - "8080"
  1. Create a directory ./nginx/conf.d
mkdir -p ./nginx/conf.d
  1. Itheima.conf write files in the directory ./nginx/conf.d
server {
    listen 80;
    access_log off;

    location / {
        proxy_pass http://app:8080;
    }
   
}
  1. Use docker-compose the starting container at ~ / docker-compose directory
docker-compose up
  1. Test Access
http://192.168.149.135/hello

Guess you like

Origin www.cnblogs.com/yuqiliu/p/12617145.html