How to read logs and debug Docker containers
Updated 11/29/2026
When something is wrong with a container, the first step is always to read the logs. Here are the debugging tools.
1. View the logs
docker logs container_name
docker logs -f container_name # live
docker logs --tail 100 container_name
2. Check why it stopped
docker ps -a # see status and exit code
docker inspect container_name
3. Enter the container
docker exec -it container_name sh
If the container does not even start, run it temporarily with a shell:
docker run -it --entrypoint sh the_image
4. Resource usage
docker stats
Shows real-time CPU and RAM per container, useful when a container uses too much.
Common problems
- Container restarting endlessly: usually a config error or a missing environment variable.
- "Port already in use": another service already uses the port, change the mapping.
- Data lost on restart: a volume is missing.
Put this guide into practice on your own VPS
EU cloud servers, billed hourly, ready in minutes, with one-click installs for dozens of apps.
See pricingRelated tutorials
Docker & containers
How networking works in Docker
Understand how containers communicate with each other and how to isolate them on separate Docker networks.
Updated 11/29/2026Docker & containersHow to keep data in Docker with volumes
Containers are ephemeral: without volumes, you lose data when you delete the container. Here is how to keep it correctly.
Updated 11/29/2026Docker & containersHow to free up disk space used by Docker
Images, stopped containers and orphaned volumes can fill your disk. Here is how to clean them up safely.
Updated 11/29/2026