Access sockets(172.17.0.x) directly from mac without -P / port forwarding

Expected behavior

docker start -d nginx
curl -v

respond with nginx index page

Actual behavior

curl hangs

curl -v

  • Rebuilt URL to:
  • Trying…
  • connect to port 80 failed: Operation timed out
  • Failed to connect to port 80: Operation timed out
  • Closing connection 0
    curl: (7) Failed to connect to port 80: Operation timed out


  • the output of:
    • Moby Menu > Diagnose & Feedback on OSX
      Docker for Mac: version: mac-v1.12.0-beta18-3-gec40b14
      OS X: version 10.11.5 (build: 15F34)
      logs: /tmp/20160707-221808.tar.gz
      [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

osx 10.11.5

Steps to reproduce the behavior

  1. docker run -d nginx
  2. docker ps # to check the container id
  3. docker inspect [container name]
  4. curl -v http://[dockerip]/
1 Like

Not forwarding ports by default is an expected and documented behaviour of Docker.

Therefore, this is not a defect.

The question isn’t about forwarding ports, though, it’s about bridging network interfaces. This behaves differently on docker in linux, so I’d argue that if it’s not a defect, it’s a discrepancy, at a minimum.

I want bridge access as linux works, not forwarding, because if I start for example a mysql container i want to access it by ip:3306 not localhost:randomPort…

So use docker run -p 3306:3306, and it’ll be visible on your host system at port 3306.

I know what are my alternatives, but if I already have an mysql locally, or another mysql container, i have to find next available port and so on…

I like docker and I would really love to see this feature on mac too, and I know that there are a lot o f people who agrees with me.

1 Like