Webserver in docker container is not reachable via the internet

Solution 1:

  1. You need to inverse the mapping -p 80:8080 to -p 8080:80 The 1st port is on the host and the second is the container's.
  2. On your work/home network, make sure to redirect, in your router/fw, the port 8080 to your docker host port 8080.

This should work: Here is the same steps I performed with my nginx container:

docker network create --driver bridge devils_network
4320854ef67c5489848c1e1f14ffaf4d65183c5e3fac5f655c038bb15aa50df7  

docker run -it -v ~/dockervolume/deus:/usr/share/nginx/html --name deus --hostname deus --network=devils_network -p 8080:80 ajnouri/nginx
root@deus:/# 

Copied an index.php file into ~/dockervolume/deus:

And browsed my public IP from my phone:

enter image description here