Docker Errors for Beginners Explained
Docker is one of the most useful tools a developer can learn, but its error messages are often terse and confusing when you're just starting out. This guide walks through the Docker errors beginners hit most often — what causes each one and exactly how to fix it.
1. "Port is already allocated"
This happens when you try to bind a container to a host port that's already in use by another container or a local process.
docker: Error response from daemon: driver failed programming external connectivity on endpoint web (...): Bind for 0.0.0.0:3000 failed: port is already allocated. # Find what's using the port docker ps # Stop the conflicting container docker stop <container_id> # Or just use a different host port docker run -p 3001:3000 myapp
2. "Cannot connect to the Docker daemon"
This means the Docker engine itself isn't running, or your user doesn't have permission to talk to it.
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? # Linux — start the service sudo systemctl start docker # Linux — add your user to the docker group (avoids needing sudo) sudo usermod -aG docker $USER newgrp docker # Windows / Mac — open Docker Desktop and wait for it to say "running"
3. "No space left on device"
Docker images, stopped containers, unused networks, and dangling volumes all consume disk space and are not cleaned up automatically.
# See how much space Docker is using docker system df # Remove stopped containers, unused networks, and dangling images docker system prune # Also remove unused images (not just dangling ones) and volumes docker system prune -a --volumes
Run docker system prune -a --volumes carefully — it deletes anything not currently used by a running container, including cached layers you may want to rebuild later.
4. "Image not found" / "pull access denied"
- Typo in the image name or tag — check spelling and that the tag (e.g.
:latest,:18-alpine) actually exists on Docker Hub - Private image, not logged in — run
docker loginbefore pulling from a private registry - Image only exists locally — if you built it with
docker build -t myapp ., it won't exist on Docker Hub; reference the local tag directly - Wrong registry — if using a private registry, prefix the image name with the registry host, e.g.
registry.example.com/myapp:latest
5. Container Exits Immediately After Starting
If docker ps shows nothing but docker ps -a shows your container with status "Exited", the main process inside the container finished or crashed.
# See what happened docker ps -a docker logs <container_id> # Common causes: # - CMD in Dockerfile runs a one-off script, not a long-running server # - The app crashed on startup (missing env var, bad config) # - Base image expects a foreground process, but CMD forks to background
6. Changes to Code Not Reflected in the Container
A common beginner confusion: editing files locally but the running container still shows old behavior. This happens because the image was built once and files were copied in at build time — it doesn't watch your filesystem for changes.
- Rebuild the image after code changes:
docker build -t myapp . && docker run myapp - For local development, mount your source folder as a volume instead:
docker run -v $(pwd):/app myapp - Use
docker-composewith avolumes:entry so this is automatic every time you rundocker-compose up
Frequently Asked Questions
This means another container, or a process on your host machine, is already using that port. Stop the conflicting container with docker ps and docker stop, or map your container to a different host port with -p.
This means the Docker service is not running. On Linux, start it with sudo systemctl start docker. On Windows and Mac, open Docker Desktop and wait for it to fully start before running docker commands.
Docker images, containers, and volumes accumulate over time and fill disk space. Run docker system prune -a to remove unused containers, networks, and images, and docker volume prune to remove unused volumes.