Troubleshooting — The Kitchen Problem Desk
Everyone eventually sees a confusing Docker error. This is the Problem Desk: what the message means, why it happened, and how to get out. Each problem follows the same Problem → Cause → Fix rhythm you know.
1 · "Cannot connect to the Docker daemon"
Every Docker command fails with this error.
Cause: The Docker Engine (daemon) isn't running. Docker Desktop is closed, or the service hasn't started.
Fix:
sudo systemctl start docker
# Open Docker Desktop from your applications
docker info
Docker commands talk to the Docker daemon. If the daemon is off, nothing works. Always check docker info first.
2 · "Port is already allocated"
docker run fails with "port is already allocated" or "address already in use."
Cause: Another container (or another program) is already using that port on your computer.
Fix:
lsof -i :8080
docker ps --filter "publish=8080"
docker stop <container-name>
docker run -d -p 9090:80 nginx
Port mapping is HOST:CONTAINER. If port 8080 on your host is taken, map to a different host port like 9090.
3 · "No space left on device"
Docker commands fail, or builds stop mid-way with "no space left on device."
Cause: Docker images, containers, and volumes accumulate over time and fill your disk.
Fix:
docker system df
TYPE TOTAL ACTIVE SIZE RECLAIMABLE
Images 15 3 4.2GB 3.1GB (73%)
Containers 8 2 120MB 95MB (79%)
Local Volumes 12 4 2.1GB 1.5GB (71%)
Build Cache 20 0 800MB 800MB
docker system prune -a --volumes
docker system prune -a --volumes removes all unused images, containers, and volumes. Only use it when you're sure you don't need the old ones.
4 · "COPY failed: file not found"
docker build fails with "COPY failed: file not found" or "no such file or directory."
Cause: The file you're trying to COPY doesn't exist in the build context, or the path is wrong.
Fix:
ls -la
pwd
cat .dockerignore
The . in docker build -t myapp . defines the build context. Docker can only access files inside that directory. Files outside it (or excluded by .dockerignore) can't be copied.
5 · "Container keeps restarting"
docker ps shows the container status as "Restarting" over and over.
Cause: The command in CMD or ENTRYPOINT is crashing immediately. Maybe a missing file, wrong path, or dependency error.
Fix:
docker logs <container-name>
docker run -it --entrypoint sh <image-name>
docker inspect <container-name> --format='{{.Config.Cmd}}'
A restarting container is usually a crash loop. docker logs tells you what's failing. Fix the command, rebuild, and try again.
6 · "permission denied while connecting to the Docker daemon socket"
Docker commands fail with "permission denied" on Linux.
Cause: Your user isn't in the docker group. Only root can talk to the Docker daemon by default.
Fix:
sudo usermod -aG docker $USER
docker run hello-world
On Linux, Docker requires either sudo or membership in the docker group. The group change takes effect after you log out and back in.
7 · "image not found" or "manifest unknown"
docker pull or docker run fails with "image not found" or "manifest unknown."
Cause: The image name is wrong, or the tag doesn't exist. Docker Hub is case-sensitive.
Fix:
docker search nginx | head -5
docker pull docker.io/library/nginx:latest
docker login
Docker Hub image names are case-sensitive. nginx ≠ Nginx. Always use lowercase, and check the tag exists.
8 · "network not found" during docker-compose
docker compose up fails with "network not found" or "no such network."
Cause: The network was removed while containers still reference it, or a previous docker compose down removed it.
Fix:
docker compose down
docker compose up -d
docker network create campus-net
docker compose up -d
docker compose down removes networks and containers. docker compose up -d recreates them. When in doubt, down then up.