This gist is an example of a load balancing setup of tomcat, haproxy and docker.
To run the example, execute the following commands on the command line:
# start up the load balancer and one tomcat instance
docker-compose up -d
# open http://localhost and reload the page a couple of times
# now we start up another tomcat instance
docker-compose scale web=2
# reload http://localhost a couple of times again
# notice how the hostname is changing based on the tomcat instances