What the message looks like
Error response from daemon: driver failed programming external connectivity on endpoint web: Bind for 0.0.0.0:80 failed: port is already allocatedCommon causes
- Another container publishes the same host port, often after switching Compose projects.
- A host service uses the port, such as nginx, Apache or Pi-hole.
- An old container is still running because
docker compose downwas never executed. - A container uses
network_mode: hostand also declares port mappings. - A
docker-proxyprocess from a removed container still holds the port.
Check
- Who listens on the port?
ss -lntp | grep ':80 ' - Which container publishes it?
docker ps --format 'table {{.Names}}\t{{.Ports}}' | grep ':80' - All ports including stopped containers
docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' - Stuck proxy processes
ps aux | grep -i '[d]ocker-proxy'
Fix
- Find and stop the container with
docker stop NAME, then rundocker compose up -dagain. - Identify the host service and either stop it or move the container to another port, for example
8080:80. - With several Compose projects, assign ports deliberately instead of mapping 80 and 443 twice.
- Clean up old containers with
docker compose down --remove-orphans. docker restartdoes not help: the port stays taken while the other process runs.
Typical scenario
A docker compose up for a new Nginx container with ports: "80:80" aborts: Bind for 0.0.0.0:80 failed: port is already allocated. On the host the Apache from the first setup is still running, or a container from an old Compose project holds the port. ss -lntp | grep ':80 ' shows which process occupies it, and docker ps -a whether it is a container.
FAQ
Can two containers both use port 80?
Not directly. Only one holds the host port. Put a reverse proxy in front and use different internal ports.
The port is taken but docker ps is empty.
Then a host process holds it. ss -lntp shows the PID and program.
How do I map to a different host port?
Change the left side of the mapping in the Compose file, for example "8080:80". The container still listens on 80 and is reachable on the host at 8080. If you want to use 80 and 443 for several services, you need a reverse proxy for that.
How do I run several web services on ports 80 and 443?
With a reverse proxy that alone occupies ports 80 and 443 and distributes to the containers by hostname. The services themselves publish no host ports but sit in a shared Docker network. Common solutions are Nginx or Traefik.
What distinguishes 'port is already allocated' from 'address already in use'?
The first message usually appears when Docker has assigned the port to another container. The second typically arises when a process outside Docker already occupies the port on the host. That helps decide whether to stop a container or a service.