Access Docker Container from iOS Simulator

I am using boot2docker to run Docker images. I know very well that I need to access the boot2docker IP address in order to access the Docker container.

Basically in the terminal this is curl $(boot2docker ip):49155

When I do it like this in Chrome or Safari everything seems fine. When I enter the address in the Safari browser in iOS Simulator (iOS 8), I get the message: Safari cannot open the page because the network connection was lost .

I tried to launch some other localhost-ish application - SimpleHTTPServer in Python, accessible through 0.0.0.0:4000 and it seems to work fine (loading the site in iOS Simulator).

Is this a bug in Docker / iOS Simulator or do I need to make some additional settings?

+6
source share
1 answer

boot2docker is a virtual machine running on your computer. Your Mac is the host, and the boot2docker is the guest. The iOS simulator is also a "guest".

Guest machines can access the network in several ways. boot2docker is configured to use NAT, which in fact means that you can get from a guest anywhere, but you can only get to a guest from your host computer. The iOS simulator is not a host machine (it has its own IP address and its own network interface), so it cannot reach the boot2docker guest.

The easiest way is port forwarding. boot2docker instructions offer something like

 boot2docker ssh -L 49155:localhost:49155 

This will cause port 49155 to redirect all connections to port 49155 in the boot2docker guest system on the host computer (currently nothing is being done).

Now from the iOS simulator you can get to your server as if it were on the host: 0.0.0.0:49155 . If you are using a physical iOS device, you will need to obtain the external IP address for your Mac and use it.

An alternative to port forwarding like this would be to use Vagrant to configure the virtual machine yourself (running boot2docker or CoreOS or any recent Linux), and this virtual machine uses a bridged network (which makes the guest accessible from outside the host).

+5
source

Source: https://habr.com/ru/post/981552/


All Articles