Unable to connect to Docker containers on OSX

I am new to Docker and I cannot connect to any containers.

I installed the Docker Toolbox . Now I'm trying to get Shipyard . I followed the steps inside the docker quick launch terminal. The instructions say:

Once deployed, the script will print the URL for the connection along with the validity information.

Shipyard installer finished:

Shipyard available at http://10.0.2.15:8080 Username: [elided] Password: [elided] 

However, I went to http://10.0.2.15:8080 in my browser and did not connect.

In another Docker quick launch terminal, I made docker ps to find out what the container is and get its IP address, and I got:

 $ docker inspect a4755 | grep IPAddress "SecondaryIPAddresses": null, "IPAddress": "172.17.0.8", "IPAddress": "172.17.0.8", 

I'm not sure why the IP was different, but I tried to connect to http://172.17.0.8:8080 , and that didn't work either. http://localhost:8080 also failed.

This also happened when I tried to launch docker-gunicorn-nginx - it all started, but I could not connect to the machine.

What gives?

+6
source share
2 answers

If you read Docker Installation on Mac OS X , you will see that on OSX Docker containers do not start on the host machine itself:

In installing Docker on Linux, your physical machine is both localhost and the Docker host. On a network, localhost means your computer. A Docker host is a computer that runs containers.

In a typical Linux installation, the Docker client, the Docker daemon, and any containers run directly on your local host. This means that you can access ports in the Docker container using standard local addressing, such as localhost: 8000 or 0.0.0.0:8376.

[...]

On an OS X installation, the docker daemon runs inside a Linux virtual machine called default. By default, the lightweight Linux virtual machine is used, created specifically to run the Docker daemon on Mac OS X. The VM starts completely from RAM, is a small load of ~ 24 MB, and boots in about 5 seconds.

In OS X, the Docker host address is the address of the Linux virtual machine. When you start the virtual machine with the docking station, it is assigned an IP address. When you start the container, the ports on the container map are displayed in the ports on the virtual machine. To see this in practice, follow the exercises on this page.

Indeed, when opening a new Docker quick launch terminal, I see:

 docker is configured to use the default machine with IP 192.168.99.100 

And, having opened http://192.168.99.100:8080 , I will return to the Shipyard. Success!

+13
source

You can try to run this command:

 docker-machine ip default 

it will return something like:

 192.168.99.100 

To get the port number:

 docker ps 

Output example (scroll right to see port mapping):

 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 113346425f20 springio/spring1 "sh -c 'java $JAVA_OP" 34 minutes ago Up 34 minutes 0.0.0.0:8080->8080/tcp pensive_kirch 

To check if it works:

curl 192.168.99.100:8080

+3
source

All Articles