Haproxy based on official image. Load balancer configuration thru environment variables.
1.7K
Create static python http server on new docker machine called http1:
docker-machine create --driver virtualbox http1
eval $(docker-machine env http1)
docker run -d -p 8080:8080 python python -m http.server 8080
curl `docker-machine ip http1`:8080
Repeat the steps once more to have at least two http servers
docker-machine create --driver virtualbox http2
eval $(docker-machine env http2)
docker run -d -p 8080:8080 python python -m http.server 8080
curl `docker-machine ip http2`:8080
Create machine for haproxy and run docker image which automatically maps environment variables to haproxy configuration. The only required environment varialbe is SERVERS. This image use creates sticky cookie. Use this image for test purposes. Https not supported.
docker-machine create --driver virtualbox loadbalancer
eval $(docker-machine env loadbalancer)
docker run -d -p 8080:80 -e SERVERS="`docker-machine ip http1`:8080;`docker-machine ip http2`:8080" vaclavnemec/haproxy:latest
curl `docker-machine ip loadbalancer`:8080
Environment variables you can specify. Please refer to official haproxy documentation
Content type
Image
Digest
Size
54.7 MB
Last updated
over 10 years ago
docker pull vaclavnemec/haproxy