How Do I Access Docker Containers from an Other Computer

How Do I Access Docker Containers from an Other Computer

I want to expose my docker container to other machines connected to the same network (if matters, wifi network).

Locally (call it PC1 for example), I expose my apache2 server as 8080:80 using docker - so now when running on PC1, I can view my website because 8080 is assigned to port 80 via apache2 container on the local docker bridge network.

What are the steps to expose 8080 from PC1 to another machine (PC2) on that same home network?

1 Answer

By using the -p 8080:80 flag on your docker run command, you've actually already exposed it to your local network. Docker manipulates iptables to expose the port(s) you specify on all the network interfaces present on your machine.

From a different computer on your LAN, you should be able to just access where LAN_IP is PC1's LAN IP address (e.g. 192.168.0.X).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Marcus Vance
Author

Marcus Vance

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.