Changing port 80 with docker


Hello, I’m running a small webserver on a Pi listening to port 80.

Now I wanted to test Pi-hole and saw that it also uses port 80.

As I’ve seen in different posts here, changing default port 80 to for example 8080 in lighttpd.conf could be a solution, but definitely not recommended because:

  1. any upgrade of pi-hole will overwrite lighttpd.conf settings and change the port back to default
  2. the block-page and transparent pixel will not be served in response to ads, and sites will take long time to finish loading if pi-hole isn’t listening to specifically port 80

So came Docker to my mind, I’m new to it and only played with a few containers. Fortunately there is an official pi-hole docker image.

I was wondering, would mapping a different port for the host but keeping port 80 for the container works even for 1. and 2.? So like this (command shortened):

docker run -d --name pihole -p 8080:80 -p 443:443 -p 53:53/tcp -p 53:53/udp

I’m pretty confident for 1. but don’t know how I can test for 2.


After several test it’s not possible.
Also didn’t pay attention enough but the readme mention it too:

You can still map other ports to Pi-hole port 80 using docker’s port forwarding like this -p 8080:80 , but again the ads won’t render properly. Changing the inner port 80 shouldn’t be required unless you run docker host networking mode.