T
T
Taras Labiak2016-02-12 20:48:35
linux
Taras Labiak, 2016-02-12 20:48:35

How to set up networking in docker on Mac OS X?

There is a home network 192.168.0.1/24 .
There is Ubuntu running in Docker Quickstart Terminal
docker run -v /Users:/Users -i -t ubuntu /bin/bash
and the only available network adapter is eth0 on the network 172.17.0.1/16 (terminal on the left)
ddc3e8b4b0b94c82a5657a51990ffa28.png
And there is a default running virtual machine created in VirtualBox by docker (terminal on the right). The output of ifconfig differs significantly from Ubuntu
c686ecccddd64cab8b598e72c6f0350a.png
. At the same time, in the network settings of VM default networks, you can see 3 adapters .
db17bd66befe4587b8afe72bb1bfc65c.png9e82014049bc45ee9c0bddf940b7542f.png9d41278aabb44e0f8ad86a07c02ba768.png
I don’t quite understand why VM default and running Ubuntu are two different virtual machines ...
, which currently has the only 172.17.0.2 (the nginx server is running there)?
ifconfig output in Mac OS X El Capitan pastebin.com/R7TfiWrb

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2016-02-18
@ghostiam

In the VirtualBox settings of the docker virtual machine, you need to configure one of the interfaces as a network bridge on en0 in Mac OS X. For some reason, the second and third adapters are the same for you, the third one is not forwarded at the moment and can be changed to a network bridge.
Now ifconfig on the virtual machine will look like this:
Next, when starting the container, make port forwarding from the container to the virtual machine on the network interface of the bridge. Parameter "-p portvirtmachine:portcontainer"
For example:

docker run --name nginx -p 8080:80 -d richarvey/nginx-php-fpm

Here nginx is running on port 80 in the container, but we are forwarding port 80 from the container to port 8080 to the virtual machine and it will be available at http://ipvirtmachine:8080/
65064f75e6ac48fea046722b19469595.jpgifconfig Mac OS X

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question