Reputation: 673
I have Grunt running a node connect (grunt-contrib-connect) web server on localhost:8080
in a docker container. I run the container with this command:
$ docker run --rm -it -p 8080:8080 js1972/yeoman:v3
.
Inside my container I run the grunt connect task with grunt develop
.
I'm on a Mac so using boot2docker. boot2docker ip
says the host ip is 192.168.59.103 so I should access the connect server with http://192.168.59.103:8080 in my browser.
However this doesn't work and I just get a safari can't connect to server message. (note that the port forwarding works just fine when I use a simple python web server like on the docker website examples.)
Any idea whats wrong here? The same process works perfectly well outside of docker. I've got a feeling its something to do with running Connect on localhost. I've tried various combinations of --add-hosts and -p localhost:8080:8080 and so on to no avail...
If it helps here's my docker file and gruntfile: https://dl.dropboxusercontent.com/u/7546923/Dockerfile https://dl.dropboxusercontent.com/u/7546923/Gruntfile.js
Rgds, Jason.
Upvotes: 3
Views: 1369
Reputation: 9894
Modify the ip of the hostname in the connect settings of the Gruntfile:
// The actual grunt server settings
connect: {
options: {
port: 8080,
// Change this to '0.0.0.0' to access the server from outside.
hostname: '0.0.0.0',
livereload: 35729
},
And open the server and reload port to the boot2docker vm:
boot2docker poweroff # vm needs to be off to modify the network settings
VBoxManage modifyvm "boot2docker-vm" --natpf1 "containergruntserver,tcp,,8080,,8080"
VBoxManage modifyvm "boot2docker-vm" --natpf1 "containergruntreload,tcp,,35729,,35729"
boot2docker up
Upvotes: 2
Reputation: 46548
Change localhost
to 0.0.0.0
.
At the moment the container is only listening for internal connections on the local interface. Using 0.0.0.0
will tell it to listen to all interfaces including the one the Docker host is connected to.
Upvotes: 4