How to read logs and debug Docker containers
Updated 10/16/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 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 10/16/2026Docker & containersHow to back up Docker containers and volumes
Save the data from Docker volumes and send it to a Backup Box, so you can restore any container.
Updated 10/16/2026Docker & containersDocker security best practices
Run safer containers: non-root users, official images, limited resources and protected secrets.
Updated 10/16/2026