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 24, 2018 in Docker by Hannah
• 18,520 points
1,175 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 24, 2018 by Kalgi
• 52,350 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
• 7,340 points
1,536 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
3,994 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
• 7,060 points
4,364 views
+2 votes
1 answer
+2 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
• 58,020 points
2,739 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
• 52,350 points
724 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
• 52,350 points
732 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP