0

I am using docker toolbox on win 10 Home and having issues with running multiple containers on different ports.

Below I attached snapshots of my VirtualBox network portforwarding settings and the running containers. Basically, I am using a common image called feedback with 2 versions: one is using port 80 (feedback-app-v1) and another uses port 8000 (feedback-app-v2). Only v1 is running while the other is not getting connected and showing

This site can’t be reached. The connection was reset.

enter image description here enter image description here

Am I missing something here? Any help is appreciated

EDIT

Dockerfile config-

FROM node

WORKDIR /app

COPY package.json .

RUN npm install

COPY . .

ENV PORT 80

EXPOSE ${PORT}

CMD ["node","server.js"]

Above is the dockerfile for v1 i.e the working example for port 80, for v2, I merely changed the port from 80 to 8000

enter image description here

The image shows the docker run commands i executed for v1(80) and v2(8000)

  • There might be such error if there is nothing listening on target port in container. Have you double checked that v2 is listening on 80? – anemyte Jul 14 '21 at 11:02
  • Hello :) thanks for replying. I am quite new to docker so I might be wrong about things and i guess you meant to ask whether v2 is listening on 3000 or not since 3000 is the host port that is connected to guest port 8000 as per virtualbox network config. Yes, i have checked that several times but its still not working. – Shiladitya Thakur Jul 14 '21 at 11:52
  • Oh sorry, I missed container names. I was confused by image names where image with v2 has a container name v1. I see now what you've meant. – anemyte Jul 14 '21 at 12:17
  • 1
    The problem is likely in the wrong mapping. See you have this rule in virtualbox: host:3000->vbox:8000. Then you have docker vbox:3000->container:8000. I guess you need to reverse that to make it working: `-p 8000:3000`, then you'll have a chain like this `host:3000->vbox:8000->container:3000`. – anemyte Jul 14 '21 at 12:22
  • Ah, my bad. I didn't notice that at first i used image v2 with container v1. But i tried out -p 8000:3000, -p 3000:8000, -p 80:8000. Only -p 80:8000 is working. This app uses port 8000 and in vbox network setting i already have 2 tcp rules: host:3000 -> guest:8000 and host:80 -> guest:80. How do i run on ports other than 80? Right now, it seems I can only run on localhost:80 – Shiladitya Thakur Jul 14 '21 at 13:18
  • 1
    If `-p 80:8000` worked try `-p 8000:8000`. On host check with `localhost:3000`. – anemyte Jul 14 '21 at 13:28
  • Oh it finally worked on 3000! I am a newbie and this port mapping seemed a bit mind boggling. Anyway, i understood it now. Thanks alot :) – Shiladitya Thakur Jul 14 '21 at 13:40

0 Answers0