Reputation: 4349
First I installed boot2docker on OSX 10.10, then I successfully ran a web container. With port redirection configuration, I can browse the web server by localhost:8080
in the browser. Now I want to access the server from other computers, in the same WLAN, by using of url my-mac-ip:8080
. I googled over and tried many ways, still not figured out the solution.
I found similar question, but iptables doesn't work for OSX.
I'm new to Docker and I'm not familiar with network configuration, please help me out! Thanks!
Upvotes: 6
Views: 3185
Reputation: 364677
You can setup temporary port forwarding as follows:
On your Mac:
$ ifconfig | grep 192
inet 192.168.1.21 netmask 0xffffff00 broadcast 192.168.1.255
inet 192.168.59.3 netmask 0xffffff00 broadcast 192.168.59.255
$ docker run -d -P --name web nginx
$ docker port web
443/tcp -> 0.0.0.0:49153
80/tcp -> 0.0.0.0:49154
$ boot2docker ssh -vnNTL 192.168.1.21:8080:localhost:49154
On a PC or any other device on the same 192.168.1 LAN, you can now access the nginx server with http://192.168.1.21:8080
See also boot2docker workarounds.
Upvotes: 0
Reputation: 576
This sounds like it isn't a Docker problem because you can access localhost:8080. I think you need to open port 8080 on your laptop to make it possible for others to access it from outside.
To open a port under Max OS X 10.10 foolowd this guide, it describes how to usw pfctl for port forwarding.
Upvotes: 4