Quantcast
Viewing all articles
Browse latest Browse all 4741

Haproxy won't work with docker

Hi everyone, I’m new on using haproxy and Ihave trubles setting up a web app with Docker.
I am using an Node.js app listening on port 8001 and it connects on a local database mongodb on port 27017. I have created a Docker compose file for configuring a Docker environment with 3 serves of the app, the DB and the haproxy server.

version: “3”
services:
app1:
container_name: app1
restart: always
build: .
ports:
- “81:8001”
links:
- mongo
networks:
- my-net
app2:
container_name: app2
restart: always
build: .
ports:
- “82:8001”
links:
- mongo
networks:
- my-net
app3:
container_name: app3
restart: always
build: .
ports:
- “83:8001”
links:
- mongo
networks:
- my-net
mongo:
container_name: mongo
image: mongo
ports:
- “27017:27017”
networks:
- my-net
haproxy:
build: ./haproxy
container_name: haproxy
links:
- app1
- app2
- app3
ports:
- “80:80”
- “8404:8404”
networks:
- my-net
networks:
my-net:
name: my-net
driver: bridge

the docker files for the haproxy is this:

FROM haproxytech/haproxy-alpine:2.4
COPY haproxy.conf /usr/local/etc/haproxy/haproxy.conf

and the docker file for the apps is the following:

FROM node:13-alpine

RUN mkdir -p /home/app

COPY ./nosql_practica4_bbdd-main /home/app

WORKDIR /home/app

RUN npm install

RUN npm run seed

#RUN npm start

CMD [“npm”, “start”]

EXPOSE 8001

The app is working if I type the ports on the browser but the haproxy isn’t working and on the logs it shows this error:
[ALERT] (8) : backend ‘app’ has no server available! docker

anyone with Docker skills that can help me understand what I have done wrong?

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>