https://github.com/sourceability/docker-dev-load-balancer
https://github.com/sourceability/docker-dev-load-balancer
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sourceability/docker-dev-load-balancer
- Owner: sourceability
- License: mit
- Created: 2018-09-20T01:07:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-11T17:17:03.000Z (almost 6 years ago)
- Last Synced: 2025-03-04T03:43:39.694Z (about 1 year ago)
- Size: 2.93 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Local load balancer for docker-compose projects
This project allows to access individual docker compose containers through `http://(.+\.)?..docker`.
This is how it works:
- A docker container runs a dns server that always returns 127.0.0.1 (exposed to localhost:10053)
- The system needs to be configured to resolve any .docker hostname with localhost:10053
- A docker container runs an nginx load balancer exposed on localhost:80 that proxies `*..docker`
http requests to `__1`. This container is attached to all the docker networks.
The containers will start when docker starts since they are configured with `restart: always`.
## Installation
```
# Start load balancer and dns
docker-compose up -d
# Give load balancer access to all the compose networks
docker network ls --filter driver=bridge --filter scope=local -q \
| xargs -I {} docker network connect {} "$(docker-compose ps -q lb)"
# Configure system to resolve all .docker domains using the spun up dns server
sudo mkdir -p /etc/resolver
sudo tee /etc/resolver/docker > /dev/null <_default "$(docker-compose ps -q lb)"
```