Three Errors, One Root Cause: You Don't Know What Docker Actually Did
Most Docker errors that eat real debugging time aren't exotic — they're one of a small handful of well-understood failure modes. Here are the three that come up constantly, what's really happening, and the fastest fix for each.
"Port Is Already Allocated"
Error response from daemon: driver failed programming external connectivity
on endpoint myapp: Bind for 0.0.0.0:8080 failed: port is already allocated
What it means: you're telling Docker to bind container port X to host port 8080, but something on your machine — another process, or another container — is already listening on host port 8080. Only one process can bind a given port at a time; this is an operating system constraint, not a Docker-specific one.
The most common actual cause: it's usually a container of your own, from a previous run, that you forgot was still up. Check first:
docker ps
If you see an old container mapped to the same port, stop it:
docker stop <container-id>
If it's not a container, find whatever process is holding the port:
# Linux / macOS
lsof -i :8080
# Windows
netstat -ano | findstr :8080
Fix without killing anything: just run your container on a different host port — the container's internal port doesn't need to match:
docker run -p 8081:8080 myapp
"Cannot Connect to the Docker Daemon"
Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
Is the docker daemon running?
What it means: the docker command you're running is a client — it doesn't do anything itself. It talks to a background daemon process (dockerd) that actually manages containers, images, and networking. This error means that daemon isn't reachable, for one of three reasons:
-
The daemon isn't running. On Linux:
sudo systemctl start docker sudo systemctl status docker # confirm it's actually upOn macOS/Windows, this usually means Docker Desktop itself isn't running — open the application, wait for it to fully start, then retry.
-
Your user isn't in the
dockergroup (Linux), so you don't have permission to talk to the daemon's socket:sudo usermod -aG docker $USERThen log out and back in — group membership changes don't apply to an already-open terminal session.
-
DOCKER_HOSTis pointed somewhere wrong — if you've been working with a remote Docker context or a VM, checkecho $DOCKER_HOSTand reset it if it's stale.