Docker-在运行时使用NGINX组合Jetty

时间:2016-09-28 20:51:12

标签: nginx docker jetty docker-compose

我是码头工人的新手。我已经通过一些教程来创建docker compose文件来创建3个Jetty,1个NGINX和1个MySQL。 NGINX充当了循环机制的LB.It正如预期的那样运作良好。

如果我扩展我的jetty实例(通过docker-compose scale jetty-one = 2),则会创建容器。但它不属于NGINX LB.我希望,我已经在NGINX的上游配置文件中进行了硬编码。请指导我并提供在运行时在LB下添加Jetty实例的解决方案,无需重启LB.

Docker Compose

lb:
  image: nginx
  ports:
   - "82:80"
  volumes:
   - /home/docker/default.conf:/etc/nginx/conf.d/default.conf
  links:
   - jetty-one:jetty1
   - jetty-two:jetty2
   - jetty-three:jetty3
jetty-one:
  image: jetty
  volumes:
   - /home/docker/webapps:/var/lib/jetty/webapps
jetty-two:
  image: jetty
  volumes:
   - /home/docker/webapps:/var/lib/jetty/webapps
jetty-three:
  image: jetty
  volumes:
   - /home/docker/webapps:/var/lib/jetty/webapps
db:
 image: mysql
 ports:
  - "3307:3306"

NGINX配置文件

upstream backend  {
  server jetty1:8080;
  server jetty2:8080;
  server jetty3:8080;
}



server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        proxy_pass  http://backend;
    }


    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;

0 个答案:

没有答案