Mac OS X, Vagrant, Docker, Nginx, Node – how do ports play together?

I have a simple nginx, node.js setup that I want to migrate into the Vagrant, Docker world. I’m not sure how to handle IPs and ports.

My goal is it to see my Hello World in the Browser, best case on port 80, simply by calling my host

  • separate applications on kubernetes cluster
  • Detach from docker run from script without killing container
  • How to connect to mongodb using docker-compose?
  • Can't connect to a firebird server on docker
  • Selenium ChromeDriver Failed to load resource: net::ERR_CONNECTION_CLOSED
  • How to update Docker image when there is new image version?
    I found the solution myself – I created a simple boilerplate here:
    Feel free to go on from here.


    var app = express();
    app.route('*').all(function(req, res) {
      res.send('Hello World!');


    upstream {
      # using the vagrant private network IP (I guess?)
      # using the node port
    server {
      # ports nginx server is listen to
      listen 80;
      listen 443;
      location / {
        # upstream proxy
        # ...


    Vagrant.configure("2") do |config|
  = "ubuntu/trusty64"
      config.vm.provision "docker"
      # settimg a hostname that matches nginx upstream (I guess?)
      config.vm.hostname = ""
      # setting a private network IP, node.js and nginx run on this IP (i guess?) "private_network", ip: ""


      Vagrant.configure("2") do |config|
        config.vm.define "nginx" do |app|
          # forward the nginx port (I guess?)
 "forwarded_port", guest: 80, host: 80
          app.vm.provider "docker" do |d|
            d.build_dir  = "./docker/nginx"
            d.vagrant_vagrantfile = "./Vagrantfile.proxy"
        config.vm.define "node" do |app|
          # forward the node port (I guess?)
 "forwarded_port", guest: 2000, host: 2000
          app.vm.provider "docker" do |d|
            d.build_dir  = "./docker/node"
            d.vagrant_vagrantfile = "./Vagrantfile.proxy"


    # ...
    EXPOSE ["80"]


    # ...
    EXPOSE ["2000"]

    Mac OS X /etc/hosts

    I was expecting to call in the browser to see my Hello World via nginx and to see the node instance. Therefore the host does not work either.

    What do I do wrong?

  • docker-compose, export environnement variables are not working in Jenkins
  • how to access docker registry v2 with curl?
  • How to use the rabbitmq docker compose yml file to build docker image?
  • How to use redirects in Docker
  • Docker: Why is /etc/resolv.conf unreadable? Breaks DNS [closed]
  • ImagePullBackOff: Kubernetes error with Nexus based Private Registry
  • One Solution collect form web for “Mac OS X, Vagrant, Docker, Nginx, Node – how do ports play together?”

    I created the fork and made pull request to your repo.

    The main idea: do not use provisioning for docker containers.

    More information your can find in this article

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