How to access Docker Container as localhost

Here’s a addition part of Docker ❤ Parse series which can be skip somehow because it’s only proof of concept in develop environments before we doing this again on real server.
Problem : Other devices in same network (e.g. iPhone) can’t access Docker container which is Parse Server for Push Notification in my case.
iOS (Swift) → Mac OSX → Docker Parse Server
Solution : Use Nginx proxy_pass
iOS (Swift) → Mac OSX → NGINX → Docker Parse Server
Install HomeBrew
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Update and Upgrade
$ brew update && brew upgrade
Install Nginx
$ brew install nginx
Start Nginx
$ brew services start nginx
Navigate to http://localhost:8080/

Forward proxy
Let’s mess with nginx config, no worry we mess with it before so just do it.
$ nano /usr/local/etc/nginx/nginx.conf
In my case, I want to forward it to Parse server on my Mac OSX.
Reveal IP
$ docker-machine ip
Error ?(this always happen when reboot tho)
ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
Try this and run above command again.
$ eval "$(docker-machine env default)"
If you lucky it will show some IP, for me it’s 192.168.99.100 and in my case I have 2 ports there to bind to which will look like this.
http://localhost:4040/ → http://192.168.99.100:4040/
http://localhost:1337/ → http://192.168.99.100:1337/
Add below context then ^O + Enter + ^X to save and quit
It will look like this (partial image, not whole file)

Restart
$ sudo nginx -t && sudo nginx -s reload
TADA! http://localhost:4040/

Access from external devices
Find current IP for both LAN and WiFi that expose to other devices.
$ ipconfig getifaddr en0 && ipconfig getifaddr en1
It shown 192.168.1.3 which mean http://192.168.1.3:4040/ is available for whole network. Let’s try it.

Rad!, To prove it really work. Do try with other devices e.g. your phone which access same WiFi/LAN network it should be fine if everything going well.
PS : Next chapter is How to setup Parse Push Notifications via Docker Parse Server. Do follow me if you’re feeling brave!
Note (ref)
You can get free $10 for DigitalOcean (which is 2 months free hosting).
You can get cheapest .io and nice UI/UX at NameCheap.