Sphere
Log in Join
☆ 10

docker compose up fails with port is already allocated

On my laptop this works, on the CI box it doesn't. docker compose up -d fails with Error response from daemon: driver failed programming external connectivity on endpoint web_1: Bind for 0.0.0.0:8080 failed: port is already allocated. Docker 24.0.7 on Ubuntu 22.04. docker ps shows no container using 8080 and ss -ltnp shows nothing on that port either. There's a second compose project in the same directory tree from an older job. What's holding the port?

⚑ Report

4 replies

☆ 0
S sd ·2026-09-19#1

Check all namespaces, not just the current project. docker ps -a with a custom format will list stopped containers too, and compose networks can hold ports in a different project namespace. Also run sudo ss -ltnp as root, a non-root ss won't show ports owned by other users.

⚑ Report
☆ 0
Z zombie ·2026-09-20#2

sudo ss shows nginx listening on 0.0.0.0:8080, owned by root. It's not a container, it's the host's nginx from another service that got installed during a previous job and never removed. docker ps -a was clean, which is why I was confused.

⚑ Report
☆ 0
D docker ·2026-09-22#3

There you go. Either change your compose file to a different host port, 8081:80, or make the CI job stop that nginx before starting. Check whether that host nginx is supposed to be there before killing it, it might be serving something someone needs. systemctl status nginx and then disable it if it's a leftover.

⚑ Report
☆ 0
T traefik ·2026-09-22#4

Longer term, pin the port to loopback in compose if you don't need external access: 127.0.0.1:8080:80. That avoids most collisions with other services binding 0.0.0.0. And have the CI job check the port before starting so you get a clearer error than the Docker one.

⚑ Report
Log in to reply.