Search code examples
dockerboot2dockergrunt-contrib-connect

How to run grunt-connect within docker container


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.


Solution

  • 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.