In the first part of this article, I showed how I split the frontend, backend and database all into their own containers, and how each could be individually scaled using docker-compose.

If you’re already familiar with docker-compose and using haproxy for load balancing against container, you might have noticed there’s a limitation in my approach, as both the backend RESTservice was exposing it’s port 8080 externally, and so I don’t think HTTP requests from the frontend browser in the app were ever passing through the haproxy to be load balanced, only the requests to load the front end on port 80 were being load balanced.

I looked into how I could configure haproxy with multiple backends, listening on different ports, but eventually came to the conclusion that adding two different haproxy containers, one load balancing for port 80 and one for port 8080 was easy to do.

I’m not sure if this is the best way to approach this, but it certainly. works. Leave me a comment if you have any suggestions.

Here’s my final docker-compose.yml:

version: '2'
services:
mongodata:
image: mongo:3.2
volumes:
- /data/db
entrypoint: /bin/bash
mongo:
image: mongo:3.2
depends_on: - mongodata
volumes_from:- mongodata
ports:- "27017"
addressbook:
image: addressbook
depends_on: - mongo
environment:- MONGODB_DB_NAME=addressbook
ports:- "8080"
links:- mongo
web:
image: docker-web-angularjs
ports:- "80"
lb-web:
image: dockercloud/haproxy
depends_on: - web
environment:- STATS_PORT=1936- STATS_AUTH="admin:your-password"
links:- web
volumes:- /var/run/docker.sock:/var/run/docker.sock
ports:- 80:80- 1936:1936
lb-addressbook:
image: dockercloud/haproxy
depends_on: - addressbook
environment:- STATS_PORT=1937- STATS_AUTH="admin:your-password"
links:- addressbook
volumes:- /var/run/docker.sock:/var/run/docker.sock
ports:- 8080:80- 1937:1937

本文数据库(综合)相关术语:系统安全软件

主题: DockerMongoDBSpringRESTUTAUTAU
分页:12
转载请注明
本文标题:Building a multi-container Spring Boot and MongoDB webapp with Docker 1.12.x ...
本站链接:http://www.codesec.net/view/480273.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 数据库(综合) | 评论(0) | 阅读(38)