Docker Community Forums

Share and learn in the Docker community.

Exposed ports not available on host


(Ondy) #1

Expected behavior

After starting the nginx example from getting-started document and exposing port 80, the nginx server should be reachable from the host.

Actual behavior

The nginx server is not reachable from the host, the browser just shows the default connection-failure page.

Information

Diagnostic ID: 250B010C-D90A-4B6E-98A2-4821DA94B42D
Docker for Mac: version: mac-v1.12.0-beta16.2
OS X: version 10.11.5 (build: 15F34)
logs: /tmp/20160629-142205.tar.gz
failure: No error was detected
[OK] docker-cli
[OK] app
[OK] menubar
[OK] virtualization
[OK] system
[OK] osxfs
[OK] db
[OK] slirp
[OK] moby-console
[OK] logs
[OK] vmnetd
[OK] env
[OK] moby
[OK] driver.amd64-linux

Steps to reproduce the behavior

  1. Install docker for mac via https://docs.docker.com/docker-for-mac/
  2. Start nginx example
    docker run -d -p 80:80 --name webserver nginx
  3. Try to connect from a host browser http://localhost - no connection.
  4. According to docker ps everything is fine:
    ➜ ~ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ef36b3e922ce nginx "nginx -g 'daemon off" 2 seconds ago Up 1 seconds 0.0.0.0:80->80/tcp, 443/tcp webserver
  5. Inside the container also everything looks fine:
    ➜ ~ docker exec -ti webserver /bin/bash root@ef36b3e922ce:/# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 12:24 ? 00:00:00 nginx: master process nginx -g daemon off; nginx 6 1 0 12:24 ? 00:00:00 nginx: worker process root 7 0 0 12:25 ? 00:00:00 /bin/bash root 18 7 0 12:25 ? 00:00:00 ps -ef
  6. According to docker inspect the container has the IP 172.17.0.2 - but from the host I am not able to connect to this IP at all.

What am I doing wrong? Is there a network interface missing? I know the docker0 from linux installation, but some forum entry mentioned that this is not available at all with docker-for-mac.
I had several older docker installations with boot2docker and docker toolbox on the same machine, but I think to have removed all old artifacts. Maybe there is still something lying around?

Thanks in advance for any help!