| sidebar_position | sidebar_label |
|---|---|
2 |
Docker Swarm |
EasyHAProxy inspects Docker Swarm services, reads their labels, and configures HAProxy automatically across all nodes.
:::tip Docker Swarm Advantages
- Container Discovery: Docker Swarm facilitates the discovery of containers within the cluster.
- Remote Node Management: Manage containers across multiple nodes while EasyHAProxy configures HAProxy seamlessly. :::
:::warning Limitations
- You cannot mix Docker containers with Swarm containers.
- This method does not work with containers that use the
--network=hostoption. See limitations for details. :::
docker network create -d overlay --attachable easyhaproxyservices:
haproxy:
image: byjg/easy-haproxy:6.0.1
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
replicas: 1
environment:
EASYHAPROXY_DISCOVER: swarm
EASYHAPROXY_SSL_MODE: "loose"
HAPROXY_CUSTOMERRORS: "true"
HAPROXY_USERNAME: admin
HAPROXY_PASSWORD: password
HAPROXY_STATS_PORT: 1936
ports:
- "80:80/tcp"
- "443:443/tcp"
- "1936:1936/tcp"
networks:
- easyhaproxy
networks:
easyhaproxy:
external: truedocker stack deploy --compose-file docker-compose.yml easyhaproxy:::danger Single Replica Only Do not add more than one replica for EasyHAProxy. To understand why, see the limitations page. :::
services:
container:
image: my/image:tag
deploy:
replicas: 1
labels:
easyhaproxy.http.host: host1.local
easyhaproxy.http.port: 80
easyhaproxy.http.localport: 8080
networks:
- easyhaproxy
networks:
easyhaproxy:
external: trueEasyHAProxy detects this service automatically and routes traffic from host1.local:80 to your container. You do not need to expose any container ports.
curl http://host1.local- Container label reference — all available labels
- Environment variable reference — configure EasyHAProxy behavior
- Docker guide — more detailed Docker examples