美文网首页
一个复杂的docker-compose.yml文件,在docke

一个复杂的docker-compose.yml文件,在docke

作者: 风吹路过的云 | 来源:发表于2019-11-01 01:12 被阅读0次

    这个docker-compose.yml文件,整合了java应用,java应用连接docker中的mysql,nginx反向代理docker中的java后端,即一切都在docker中,然后它们互相关联

    version: '3.7'
    services:
    
      assembly-go:
        image: 192.168.8.1:5000/assembly-go:v2
        container_name: assembly-go
        networks: 
          - web_net
        restart: always
        tty: true
        volumes:
          - /data/project/assembly-go/config.yml:/app/conf/config.yml
        #ports:
          #- "9090:8080"
        environment: 
          - hostname:assembly-java.xxxx.com
        extra_hosts: 
          - assembly-java.xxxx.com:172.50.0.30
    
      assembly-java:
        image: 192.168.8.1:5000/assembly-java
        container_name: assembly-java
        restart: always
        tty: true
        volumes:
          - /data/project/assembly-java/config:/config
          - /data/logs/:/logs/
        working_dir: /opt/server
        #ports:
          #- 8080:8080
        networks: 
          - web_net
        depends_on: 
          - db_mysql
        environment: 
          - hostname:assembly-go.xxxx.com
        extra_hosts: 
          - assembly-go.xxxx.com:172.50.0.30
    
      db_mysql:
        image: mysql:5.7.25
        container_name: mysql
        networks: 
          - web_net 
        restart: always
        tty: true
        ports:
          - 3306:3306
        environment:
          - TZ=Asia/Shanghai
          - MYSQL_ROOT_PASSWORD=root
        volumes:
          - /data/conf/mysql/my.cnf:/etc/mysql/my.cnf
          - /data/mysql/data:/var/lib/mysql 
    
      openresty:
        image: openresty/openresty
        container_name: openresty
        networks: 
          web_net: 
            ipv4_address: "172.50.0.30" # openresty指定ip,是为了assembly-go.xxxx.com与assembly-java.xxxx.com互相http请求
        restart: always
        tty: true
        ports:
          - 80:80
        ulimits:
          nofile:
            soft: 2048
            hard: 2048
        environment:
          - TZ=Asia/Shanghai
        links: 
          - assembly-go:ass-go          #ass-go是容器assembly-go的别名,在openresty的upstream中会用到
          - assembly-java:ass-java
        volumes:
          - /data/openresty/conf:/usr/local/openresty/nginx/conf
          - /data/openresty/logs:/usr/local/openresty/nginx/logs
          - /data/openresty/html:/usr/local/openresty/nginx/html
          - /data/wwwroot/assembly-fed/:/data/wwwroot/assembly-fed/
    
    
    
    networks: 
      web_net:
        ipam:
          config:
          - subnet: 172.50.0.0/24   #子网
    
    

    openresty的upstream部分

    #assembly-go
    upstream assembly-go {
        server ass-go:8080  weight=5 max_fails=3 fail_timeout=30s;
    
        #check interval=10000 rise=1 fall=1 timeout=1000 type=http;
        #check_keepalive_requests 1;
        #check_http_send "HEAD / HTTP/1.0\r\n\r\n";
        #check_http_expect_alive http_2xx;
    }
    #assembly-java
    upstream assembly-java {
        server ass-java:8080  weight=5 max_fails=3 fail_timeout=30s;
    
        #check interval=10000 rise=1 fall=1 timeout=1000 type=http;
        #check_keepalive_requests 100;
        #check_http_send "HEAD /static/check.html HTTP/1.0\r\n\r\n";
        #check_http_expect_alive http_2xx;
    }
    

    相关文章

      网友评论

          本文标题:一个复杂的docker-compose.yml文件,在docke

          本文链接:https://www.haomeiwen.com/subject/gtixbctx.html