Mac: how to remotely access a server running inside a docker container from other computers?

First I installed boot2docker on OSX 10.10, then I successfully executed the web container. With the port forwarding configuration , I can view the localhost:8080 web server in a browser. Now I want to access the server from other computers in the same WLAN using the url my-mac-ip:8080 . I googled and tried many ways, still did not understand the solution.

I found a similar question , but iptables does not work for OSX.

I am new to Docker and I am not familiar with network setup, please help me! Thanks!

+5
source share
2 answers

This doesn't seem to be a Docker problem, because you can access localhost: 8080. I think you need to open port 8080 on your laptop so that others can access it from the outside.

To open a port under Max OS X 10.10 foolowd is a guide , it describes how to use pfctl to forward ports.

+3
source

You can configure 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 network, you can now access the nginx server using http://192.168.1.21:8080

See also boot2docker workarounds .

0
source

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


All Articles