How to run local server in host?

I’ve just installed nodejs using docker, and I run a test server:

docker exec -i -t my-running-app bash
root@46593eb5df5c:/usr/src/app# npm start
npm info it worked if it ends with ok
npm info using npm@2.15.1
npm info using node@v4.4.3
npm info prestart foo@
npm info start foo@

> foo@ start /usr/src/app
> node server.js

Server running at

In the docker image, I am exposing port 8000, but I don’t know how would I browse into the node server inside container from the host?

  • How come that `docker-compose up` throws an error where `docker run` works fluently
  • Docker nginx minitet
  • Importing test library 'SSHLibrary' fails with the ImportError “Importing Paramiko library failed. Make sure you have Paramiko installed.”
  • NLTK is not working in docker
  • Docker: How Do I remove all images used to build a container?
  • Docker images wont run in background
  • if I just browse to I get:

    This site can’t be reached refused to connect.

    I am on ubuntu 14.04, so, how would I view that deckorized server?

  • Docker Java Client in JMeter
  • Using confluent-kafka python client in alpine container
  • Doubts about Docker with dcm4chee
  • Since docker shares host kernel, why most docker images contain the kernel stuff?
  • Pull image from local docker registry with IP
  • Storage requirement when using for AWS ECS
  • 2 Solutions collect form web for “How to run local server in host?”

    First of all try putting all the container start up commands to Dockerfile (where you build you docker image), i.e. you need to npm start and to expose port 8000, you should add to Dockerfile:

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

    You need to start you instance of the application with port mapping:

     docker run -p public_port:8000 -d my-running-app

    It will create a communication tunnel from “outside” world (public_port, could be the same – 8000, or whichever you need) to docker image

    You need to map your container Port to your Host port:

    docker exec -p 8000:3000

    for example maps your 8000 container port to your 3000 host port.

    By default Docker containers can make connections to the outside world, but the outside world cannot connect to containers. Each outgoing connection will appear to originate from one of the host machine’s own IP addresses thanks to an iptables masquerading rule on the host machine that the Docker server creates when it starts..

    Docker doc for binding Ports

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.