Pular para o conteúdo principal

Docker

EasyHAProxy inspects running Docker containers, reads their labels, and configures HAProxy automatically.

Limitations
  • You cannot mix Docker containers with Swarm containers.
  • This method does not work with containers that use the --network=host option. See limitations for details.

Step 1 — Create a shared network

docker network create easyhaproxy

It's recommended to use an external network so EasyHAProxy and your app containers can communicate.

Step 2 — Run EasyHAProxy

docker run -d \
--name easy-haproxy-container \
-v /var/run/docker.sock:/var/run/docker.sock \
-e EASYHAPROXY_DISCOVER="docker" \
-p 80:80 \
-p 443:443 \
-p 1936:1936 \
--network easyhaproxy \
byjg/easy-haproxy

Mounting /var/run/docker.sock is required so EasyHAProxy can query the Docker API.

Step 3 — Label your container

docker run -d \
--label easyhaproxy.http.host=example.org \
--label easyhaproxy.http.port=80 \
--label easyhaproxy.http.localport=8080 \
--network easyhaproxy \
my/image:tag

EasyHAProxy detects this container automatically and routes traffic from example.org:80 to port 8080 in your container. You do not need to expose any container ports.

Step 4 — Verify

Open http://example.org in your browser (or curl http://example.org). Traffic should reach your container.


Full options


Open source ByJG