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?

  • Appending to base image's ENTRYPOINT
  • OrientDB “ Error on moving existent database”
  • Increasing mysql max_connections to 1024 in a docker container
  • Saving docker credentials in docker config
  • “Memory used” metric: Go tool pprof vs docker stats
  • php mysql docker exception ssl
  • 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 daemon log for Docker for Mac
  • Cannot connect to the daemon docker in a docker image of docker
  • All job data lost when running Jenkins in Docker and when Jenkins container is stopped
  • Containers - What are their benefits, if they can't run across platform
  • Docker and Github Integration - Where did the Github Files go?
  • hazelcast cluster inside elastic beanstalk docker
  • 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.