Unable to access my first container (on 172.17.0.2)

Hi all, first post - please excuse incorrect placing or details.

I’ve just started up a Docker Wildfly container on Windows Toolbox ((i’m running Windows 10 Home). If I docker inspect{my_container} ( see an IPAddress of 172.17.0.2 but if I try and connect to that on any of the mapped ports (9990 and 8080) connection is refused.

I’ve followed this:

which would suggest that it should work, but I wonder whether the host binds this 172.x.x.x address to something in my local range 192.x.x.x or something?

If I try using the Kitematic GUI, I can click on the ‘settings’ tab it shows me 192.168.99.100 for a similar Wildfly container.

Any idea how I can find the appropriate IP address of a simple container I setup using the CLI?

Many thanks
Zzeetee

The 172.17.0.2 IP address is internal to the virtual machine that is running the Docker engine. You won’t be able to access it from your Windows host. The actual IP address of that virtual machine should be 192.168.99.100 which is the IP that ports would be mapped to if, in fact, you mapped any ports.

Assuming you used the example from Docker Hub:

docker run -p 8080:8080 -p 9990:9990 -it jboss/wildfly /opt/jboss/wildfly/bin/standalone.sh -bmanagement 0.0.0.0

The container ports will be mapped to http://192.168.99.100:8080 and http://192.168.99.100:9990 respectively.

~jr

Wonderful - many thanks, this appears to be true!

In order that I can help myself in the future - how are you able to know that it presented on 192.169.99.100 ? Is this something that I can query through an interface?

I don’t use Windows (I’m on a Mac) but if I remember correctly you could use:

docker-machine ip

and it would return the IP address of the virtual machine that Docker Toolbox is using.

When I did use Docker Toolbox for Mac I would see the VM when it was brought up and I would get this message of the day:



                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/


docker is configured to use the default machine with IP 192.168.99.100
For help getting started, check out the docs at https://docs.docker.com

That would tell me that the IP address was 192.168.99.100. Also, Docker Toolbox was using VirtualBox when I use to use it so I could open the VirtualBox GUI and check what the IP address was for the virtual machine.

Either way 192.168.99.100 is the default IP so it’s just something you remember after a while.

~jr

The docker inspect IP address is basically useless and you should never look it up.

If you’re running on Docker Toolbox, you need to do two things:

(1) Publish a port from your container using docker run -p 12345:8080 -p 12346:9990; and

(2) Access the service as http://192.168.99.100:12345 or …:12346.

The two ports for -p are an external and internal TCP port number, so port 12345 on the outside maps to port 8080 inside the container. These could match if you wanted to.

Thanks people, you’ve been amazing. All your answers worked brilliantly.

Being new to docker is a bit odd! I can’t quite work out what will happen when I want to run two different containers on two different IP addresses, but I’ll pull down a tomcat container and find out!

Thanks so much

Matt