Load balance docker swarm

+1 vote

I have docker swarm mode on one HAProxy container and three python web apps. The container with HAProxy is expose to port 80 and should load balance three containers.

Here is my docker-compose.yml file:

version: '3'
services:
  scraper-node:
    image: scraper
    ports:
      - 5000
    volumes:
      - /profiles:/profiles
    command: >
      bash -c "
        cd src;
        gunicorn src.interface:app \
          --bind=0.0.0.0:5000 \
          --workers=1 \
          --threads=1 \
          --timeout 500 \
          --log-level=debug \
      "
    environment:
      - SERVICE_PORTS=5000
    deploy:
      replicas: 3
      update_config:
        parallelism: 5
        delay: 10s
      restart_policy:
        condition: on-failure
        max_attempts: 3
        window: 120s
    networks:
      - web
  proxy:
    image: dockercloud/haproxy
    depends_on:
      - scraper-node
    environment:
      - BALANCE=leastconn
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - 80:80
    networks:
      - web

Everything works fine but when I try to get to http://localhost I get an error message:

<html>
  <body>
    <h1>503 Service Unavailable</h1>
    No server is available to handle this request.
  </body>
</html>
Aug 23, 2018 in Docker by Hannah
• 14,070 points
108 views

1 answer to this question.

0 votes

There could be two possibilities 

  1. The command in docker-compose.yml file should be one line.
  2. The scraper image should expose port 5000 
answered Aug 23, 2018 by Kalgi
• 40,460 points

Related Questions In Docker

0 votes
1 answer

How do I scale in Docker Swarm Mode W/Terraform Digital Ocean Load Balancing

The solution you could build for Digital ...READ MORE

answered Jun 19, 2018 in Docker by shubham
• 6,890 points
203 views
0 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
1,003 views
0 votes
1 answer

docker swarm throwing an error “swarm already part of swarm”

You run the docker swarm init to create ...READ MORE

answered Aug 22, 2018 in Docker by Nilesh
• 6,880 points
832 views
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,540 points
156 views
0 votes
1 answer

Can you use docker-compose files to start services in Docker 1.12 swarm-mode?

Yess, you can. you must download/install the ...READ MORE

answered Aug 10, 2018 in Docker by Kalgi
• 40,460 points
39 views
0 votes
1 answer

Docker-Compose with Docker 1.12 “Swarm Mode”

you can run docker service commands on ...READ MORE

answered Aug 10, 2018 in Docker by Kalgi
• 40,460 points
47 views