osx - Vagrant, Docker, and Node.js on Mac OS X -


i've been banging head against wall entire day on this, help. running vagrant on mac os x, , want run docker container simple node.js 'hello world' server running inside. want able access server form browser.

here vagrantfile.proxy (for running docker server):

vagrantfile_api_version = "2"  vagrant.configure(vagrantfile_api_version) |config|   config.vm.box = "hashicorp/precise64"   config.vm.provision "docker"   config.vm.provision "shell", inline:     "ps aux | grep 'sshd:' | awk '{print $2}' | xargs kill"    config.vm.network :forwarded_port, guest: 8888, host: 8888 end 

here vagrantfile:

# -*- mode: ruby -*- # vi: set ft=ruby :  # vagrantfile api/syntax version. don't touch unless know you're doing! vagrantfile_api_version = "2"  vagrant.configure(vagrantfile_api_version) |config|    # tells vagrant build image based on dockerfile found in   # same directory vagrantfile.   config.vm.define "nodejs" |v|     v.vm.provider "docker" |d|       d.build_dir = "."       d.ports = ['8888:8888']       d.vagrant_vagrantfile = "./vagrantfile.proxy"     end   end    config.vm.network :forwarded_port, host: 8888, guest: 8888 end 

here dockerfile:

from ubuntu:14.04 maintainer sean  run apt-get update run apt-get install -y python-software-properties python run echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list run apt-get update run apt-get install -y nodejs run mkdir /var/www  add app.js /var/www/app.js  cmd ["/usr/bin/nodejs", "/var/www/app.js"]  expose 8888 

and here id app.js (the node.js simple server):

var http = require('http'); http.createserver(function (req, res) {   res.writehead(200, {'content-type': 'text/plain'});   res.end('hello world\n'); }).listen(8888, '127.0.0.1'); console.log('server running @ http://127.0.0.1:8888/'); 

i start system using 'vagrant --provider="docker"'. check server started using 'vagrant docker-logs', shows console output. try

'curl http://localhost:8888' 

but 'curl: (52) empty reply server' every time.

what missing?

the problem trying run nodejs server on 127.0.0.1, rather 0.0.0.0. full, revised source can found @ here.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -