Docker Community Forums

Share and learn in the Docker community.

Port 80 used by lighttpd, need to bind new port for Pi-Hole

Hi all! I am brand new to Docker, have been using it a couple of days now. I have a Pi 4 running full Raspberry Pi OS. I am stuck on binding a new port, port 80 is in use by lighttpd. So I know I need to bind a new port but I am really struggling here and I think it is something simple.

Here is my docker-compose.ysl:

version: “3”

pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- “53:53/tcp”
- “53:53/udp”
- “67:67/udp”
- “80:80/tcp”
environment:
TZ: ‘America/Detroit’
WEB_PORT: ‘8080’
WEBPASSWORD: ‘DOTHEBENDER’
# Volumes store your data between container upgrades
volumes:
- ‘./etc-pihole/:/etc/pihole/’
- ‘./etc-dnsmasq.d/:/etc/dnsmasq.d/’
# Recommended but not required (DHCP needs NET_ADMIN)
# GitHub - pi-hole/docker-pi-hole: Pi-hole in a docker container
cap_add:
- NET_ADMIN
restart: unless-stopped

When I run sudo docker-compose up -d I receive the following error:

ERROR: for pihole Cannot start service pihole: driver failed programming external connectivity on endpoint pihole (9a77bc8e110b9b48b0aa9b311bcf0dbe22cf5804020eec2d929333dc20059a4b): Error starting userland proxy: listen tcp4 0.0.0.0:80: bind: address already in use
ERROR: Encountered errors while bringing up the project.

I’d like to pick a new port, it doesn’t need to be 8080 either. I can define my own.

Good morning and welcome,
the simple answer is: modify the line - “80:80/tcp”
The first port-number is the port propagated to the outside world.
The second port-number is the port where the service is listening to within the container.
So to change the port pihole is listening to on the outside world change this line to something like - “8080:80/tcp” and your pihole-service will be accessible on port 8080 on your host’s ip-address :slight_smile:

That was it! Thank you kindly. Now I understand.