I’m trying to spin up a docker swarm to test locally. However, when i try and curl my API through haproxy,
$ curl http://localhost/api/fish/
curl: (52) Empty reply from server
I’ve tested this configuration with a non swarm docker-compose file and it behaves correctly.
Here’s my swarm compose file:
version: '3'
services:
api:
image: fish/api
ports:
- 8001
environment:
- SERVICE_PORTS=8001
networks:
- "po-net"
deploy:
replicas: 5
update_config:
parallelism: 5
delay: 10s
restart_policy:
condition: on-failure
max_attempts: 3
window: 120s
proxy:
image: dockercloud/haproxy
depends_on:
- api
environment:
- BALANCE=leastconn
volumes:
- /var/run/docker.sock:/var/run/docker.sock
ports:
- 80:80
networks:
- "po-net"
deploy:
placement:
constraints: [node.role == manager]
networks:
po-net:
driver: overlay
It looks like the services are starting as expected:
ID NAME MODE REPLICAS IMAGE PORTS
2aicvkmrfxf9 fish_proxy replicated 1/1 dockercloud/haproxy:latest *:80->80/tcp
i1ovljnq49o5 fish_po-postgres replicated 1/1 fish/po-postgres:latest
keqymi99vji1 fish_api replicated 5/5 fish/api:latest *:30000->8001/tcp
And all the log outputs for the api say its awaiting connections on port 8001.
Is there something im doing wrong with haproxy? I would expect the above config to route from 80 on host to next available fish_api on container port 8001