Docker Community Forums

Share and learn in the Docker community.

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


(Radut) #1

Expected behavior

docker start -d nginx
curl -v http://172.17.0.2/

respond with nginx index page

Actual behavior

curl hangs

curl -v http://172.17.0.2

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

Information

  • 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]/

(Juti Noppornpitak) #2

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

Therefore, this is not a defect.


(Arachnid) #3

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.


(Radut) #4

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…


(David Maze) #5

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


(Radut) #6

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.