Is it possible to access an docker service from an external device? I built the service via fig and exposed the port 3000. I use fig with docker-osx, so docker is running inside a virtualbox.
Now I need to access the service provided from an external device (i.e. a mobile phone or tablet).
At the moment I could only access the service with localdocker:3000 from the machine hosting the VirtualBox-Environment.
For those using OSX (and Windows) for testing, Docker creates a virtual machine; this works a little differently than running on a Linux-based system.
Try the following:
docker-machine ip
This will return the virtual machine's IP. In my example, it's
192.168.99.100
Running docker ps
will show you the port mappings (cleaned up the table below a bit)
$ docker ps
CONTAINER ID IMAGE STATUS PORTS NAMES
42f88ac00e6f nginx-local Up 30 seconds 0.0.0.0:32778->80/tcp
0.0.0.0:32778->80/tcp
means docker is mapping 32778 (a randomly assigned port) on my machine (in this case the virtual machine) to my container's port 80.
You can also get this information from docker port 42f88ac00e6f 80
(42f88ac00e6f being the container ID or name)
In order to access nginx on the container, I can now use the virtual machine's ip:32778
http://192.168.99.100:32778/ will forward to my docker container's 80 port (I use this to test locally)
Obviously, the port above will not be accessible from the network but you can configure your firewall to forward to it =)