compose icon indicating copy to clipboard operation
compose copied to clipboard

docker-compose up host port mapping problem

Open umair-khokhar opened this issue 8 years ago • 2 comments

I have a node app that listens on port 8000, I containerized it using following Docker file

FROM node:carbon
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install -g nodemon
RUN npm install
COPY . .

EXPOSE 8000
CMD [ "nodemon", "start" ]

My compose file looks like this:

version: '3'
services:
  node:
    build:
      context: .
      dockerfile: node.dockerfile
    ports:
      - "8000:8000"
    image: console:cp
    volumes:
      - .:/usr/src/app

I have ensured the node app listens on all interfaces i.e. 0.0.0.0. But still whenever I type http://localhost:8000 it says this site cannot be reached.

When I run following inspect command to list all port bindings it returns: 8000/tcp -> 8000 docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' a5c17883fd5c

Any ideas? I am pulling my hairs at the moment.

I am using docker-compose up command.

Versions

Docker version 17.12.0-ce, build c97c6d6 docker-compose version 1.18.0, build 8dd22a9 Mac 0SX 10.13.2

umair-khokhar avatar Mar 13 '18 22:03 umair-khokhar

  1. Please use the forums for support
  2. Is there any info in your application logs that could indicate what's wrong? Have you made sure your service is running?

shin- avatar Mar 13 '18 23:03 shin-

Yes the service is running fine. I will post on forums as well.

Sent from my iPhone

On Mar 13, 2018, at 7:29 PM, Joffrey F [email protected] wrote:

Please use the forums for support Is there any info in your application logs that could indicate what's wrong? Have you made sure your service is running? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

umair-khokhar avatar Mar 14 '18 02:03 umair-khokhar