Previously I was using the Docker toolkit and could use docker-machine inspect <machine-name> to find the IP of the docker machine, in order to view the pages being served by the container within.

I have upgraded to the docker beta client (for mac) and cannot find where the pages are being served.

I assume because it's docker pure and not docker-machine I would see the exposed ports on localhost. But they are not open. Even via kitematic I navigate through to the exposed port (80) but see nothing.

$ docker inspect tiny_cori | jq '.[].HostConfig.PortBindings'
  "80/tcp": [
      "HostIp": "",
      "HostPort": "80"

$ docker inspect tiny_cori | jq '.[].NetworkSettings.IPAddress'

$ curl

$ docker exec -t -i tiny_cori /bin/bash

root@f1c303f60a15:/# curl localhost:80/status

root@f1c303f60a15:/# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1
    link/sit brd
3: ip6tnl0@NONE: <NOARP> mtu 1452 qdisc noop state DOWN group default qlen 1
    link/tunnel6 :: brd ::
4: ip6gre0@NONE: <NOARP> mtu 1448 qdisc noop state DOWN group default qlen 1
    link/gre6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00
26: eth0@if27: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
    inet scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:acff:fe11:2/64 scope link
       valid_lft forever preferred_lft forever

Is really the IP of my container? If not, where can I find what the IP is? Or do I have a port mapping problem?


You're looking at the IP address inside the container which is and only exists "inside" the docker containers (and between them).

The IP address you want to connect to is your host machines IP address. Do an ifconfig on your Mac and find the right one (typically 192.168.x.y or 10.x.y.z). Localhost should also work from outside the container.

  • 8
    Not sure who downvoted this but it's actually the correct answer. With Docker for Mac, there is no longer an intermediary VM with a separate machine IP address. Hitting the host (either via IP or localhost) should forward the requests to the container as long as the ports are mapped correctly. – DNJohnson Jul 22 '16 at 12:33
  • Thanks. I was confused why this had been downvoted (twice). Maybe because it just seems too simple to be the actual answer. – Mikael Kjær Jul 24 '16 at 3:39
  • I didn't downvote this. But I suspect there's a subset of users who, for whatever reason, this straightforward answer doesn't (or didn't) work. I'm marking as correct. – Synesso Aug 2 '16 at 23:55
  • 2
    Well heres an interesting thing - on OS X when I go to my xHyve VM via screen command and run curl localhost:8080 - I get response from one of the containers. But if I do the same in OS X terminal - connection refused. How can this happen? – mvmn Dec 13 '16 at 11:10
  • 1
    P.S. This happened to a container created via docker-compose. – mvmn Dec 13 '16 at 11:11

type following command and you will get your docker container ip

$docker inspect <docker-container-name>

Scroll down and you will get IP-address under "NetworkSettings"

  • Thank you. I neglected to mention that I tried this & it didn't work. My question has been updated. – Synesso May 24 '16 at 7:51
  • Right, but you can't ping it. I suspect that this is why the above correct answer gets downvoted. The question I am left with is whether there is a way to bridge to the network on the virtual host. The virtual host is still there if better integrated into MacOS, and I'm sure you can ping these IP addresses from there, but can't I bridge to that network so they are locally available on the Mac? – Gerry Gleason Nov 11 '16 at 11:03

Docker for Mac runs on IP address

  • 1
    that is not entirely a false statement :P – jonas Sep 23 '16 at 19:20
  • In fact, this was the most straightforward answer that solved my problem. – James Apr 18 '17 at 0:08

The ip address is explicitly mentioned in the output to docker ps.

$ docker ps
c785a183b376        ...>80/tcp, 443/tcp

$ curl

Furthermore, localhost is not the same as

  • 5 means all ip addresses on the current machine and is usually used when listening, not connecting. I don't understand how the above curl would even work. – Mikael Kjær May 24 '16 at 8:46
  • 2
    The is the ip address the service is bound to in the container, and means nothing in the context of the host running it. the output under the PORTS column is saying that the container's port 80 ( is mapped to port 80 locally (80/tcp), as well as port 443 locally. – Kevin Aug 2 '16 at 20:14
  • 1
    No, it isn't the same, but as pointed out, isn't an IP address, it is a signal to listen that I want all of them including localhost. In the context of connecting they are the same unless the service is bound to a specific IP (localhost or the external IP). – Gerry Gleason Nov 11 '16 at 11:13

I believe that is for localhost.

To get the docker id that running on your Mac. Run "ifconfig" in the terminal and will have it in the result besides the

Mostly something like 192.168.x.y

Hope it helps.


From 18.03 onwards the recommendation is to connect to the special DNS name host.docker.internal, which resolves to the internal IP address used by the host.

see https://docs.docker.com/docker-for-mac/networking/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.