title: how to configure node app and haProxy in docker container?
body: <p>I trying to configure my node app (will scale) and haProxy docker container in ubuntu VM.
  i don't understand how it work? how i have to configure docker-compose file ho make it work properly.
  My node app work at 8080 port and i can see one in my browser (with port binding from VM(guest:80 to host:8080), or open VM ip in chrome), but i dont expose him(port 8080) in dockerfile or docker-compose. should it be so?</p>
  
  <p>since apps work on 8080 port, i have to bind him to another port in virtual machine (as example 8080) with haproxy, but it work only when i bind 80 to 80, how? i dont have app at this port.
  my docker-compose</p>
  
  <pre><code>  version: "3"
      services:
        node:
          build:
            context: .
            dockerfile: dockerfile
          user: "node"
          networks:
            - back-tier
          working_dir: /home/node/app
          environment:
            - NODE_ENV=production
          volumes:
            - ./:/home/node/app
        lb:
          image: 'dockercloud/haproxy:latest'
          links:
            - node
          volumes:
            - /var/run/docker.sock:/var/run/docker.sock
          ports:
            - 80:80 #(node work on port 8080)
          networks:
            - front-tier
            - back-tier
          depends_on:
            - node
          environment:
            - BALANCE=leastconn
      networks:
        front-tier:
          driver: bridge
        back-tier:
          driver: bridge
          internal: true
  </code></pre>
  
  <p>my dockerfile for web app</p>
  
  <pre><code>FROM node:12.13.1-alpine3.10
  WORKDIR /home/node/app
  RUN npm install -g nodemon
  #RUN npm install
  
  CMD [ "nodemon", "index.js" ]
  </code></pre>
  
  <p>thank</p>