CloudLinux.ro
Docker & containers

How to read logs and debug Docker containers

Updated 7/20/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 pricing

Related tutorials