boot2docker on windows – Can't access exposed port

I’ve installed boot2docker (full install) on Windows 7 and am trying to run the container port redirection demo:

docker run --rm -i -t -p 80:80 nginx

Which looks like it isn’t quite finishing properly, it just stops and looks like this:

  • TravisCI build succeeds even when tests fail
  • Dockerfile: $HOME is not working with ADD/COPY instructions
  • Docker cp error: Path not specified
  • Docker - Enable Remote HTTP API with SystemD and “daemon.json”
  • Could not find gem mysql2 even though it's in the Gemfile and bundle install is in the Dockerfile
  • Nginx conf wont work
  • enter image description here

    When I open another git bash shell and run boot2docker ip I get 192.168.59.103, and when I pop that in chrome I get Error code: ERR_CONNECTION_TIMED_OUT

    It works fine for me with plain docker on Ubuntu 14.04. What else do I need to do to make it work with boot2docker on windows?

  • unable to run docker as non-root user?
  • Setup subdomains in docker environment
  • Selenium webdriver with Phantomjs save_screenshot doesn't work in Docker container
  • Docker UCP Content Trust not work, notary
  • Docker pushing containers to private registry
  • Azure App hosted docker port 25
  • 2 Solutions collect form web for “boot2docker on windows – Can't access exposed port”

    Looking more closely, my problem is the same as this question: Docker, can’t reach “rails server” development from localhost:3000 using docker flag -p 3000:3000

    The answer to that question that worked for me was this one, which simply says to run

    boot2docker ssh -L 8080:localhost:80
    

    at the terminal before starting boot2docker

    In my case I do this (from a git bash terminal):

    boot2docker init # from https://github.com/boot2docker/boot2docker
    boot2docker up
    boot2docker ssh -L 8787:localhost:8787 # sets up port forwarding and starts boot2docker
    docker run -d -p 8787:8787 cboettig/rstudio # starts the container I want
    

    then go to my web browser in windows and point it to http://localhost:8787/ and I get a server instance of RStudio. When I’m done:

    docker rm -f $(docker ps -a -q) # delete all containers
    

    UPDATE: downgrading to an earlier version of VirtualBox will fix this

    After struggling with folder sharing I regressed through previous versions of VirtualBox and found that with version 4.3.12 I could enable folder sharing and have the port forwarded exactly according to the official instructions, that is I could access my docker container at 192.168.59.103. So downgrading VirtualBox is another option for working around this problem.

    ANOTHER UPDATE: updating to the new release of v1.3.1 of boot2docker will fix this

    This release just came out a week ago and includes VirtualBox Guest Additions, which simplifies all of this. I now simply do

    boot2docker ssh # start boot2docker
    docker run -d -p 8787:8787 -v /c/Users/foobar:/home/rstudio/foobar rocker/rstudio  
    

    And I get everthing working as expected and can log into RStudio in my browser at http://localhost:8787/ (linux) or http://192.168.59.103:8787 (Windows) and it just works.

    In this case I’ve also got folder sharing working with, /c/Users/foobar corresponding to an existing folder on my computer at C:/Users/foobar, and foobar can be anything. With this method I can read and write files both ways between Windows and RStudio and I don’t need to connect to a special IP address like the samba method does in the official docs

    I had this problem too after a couple of failed attempts to boot2docker start. This created multiple entries of host-only networks configured on VirtualBox (VirtualBox Host-Only Ethernet Adapter #2, VirtualBox Host-Only Ethernet Adapter #3), and probably the boot2docker’s VM was using a bad one.

    I cleaned up using Virtualbox standard UI, leaving only one of the networks and now everything works fine.

    I’m using boot2docker 1.5.0.

    Just to register something that happened to me, and made me lose a couple of hours.

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