Can't access service running in docker

Viewed 4932

I'm unable to access a nodejs based service via http://localhost:8000 running in a docker image. I'm using Docker for Mac (https://docs.docker.com/docker-for-mac/)

I'm following the tutorial here https://nodejs.org/en/docs/guides/nodejs-docker-webapp/.

The server runs on port 8000. I start the docker image with the following:

$ docker run -p 8000:8000 -d geuis/node-server:latest

If I run docker ps I see:

CONTAINER ID        IMAGE                      COMMAND             CREATED             STATUS              PORTS                    NAMES
9fa2e446918b        geuis/node-server:latest   "npm start"         6 seconds ago       Up 5 seconds        0.0.0.0:8000->8000/tcp   unruffled_lewin

If I docker exec -it 9fa2e446918b /bin/bash I can access the docker vm and I can curl http://localhost:8000 and access the server from inside the container.

However, I try the same curl http://localhost:8000 from my system terminal and its not accessible.

Not sure what I need to do next.

1 Answers
Related