For system, network and cloud administrators

How to run Docker in debug mode and view container logs?

  1. Execute the Docker events command:
docker events &
Docker events command

By this point, any Docker command that you’ll run next will be viewed with more logs.

  1. Execute your Docker command (for example: run a container or create an image):
docker container run -d --name nginx-r-p-container --publish 80:80 nginx-reverse-proxy:latest
Getting the Docker instance ID of the container
  1. Check the logs of the Docker instance ID that concerns you:
docker logs 250629587af532239d8b165e924f9217134cf662a5ba1ce0855c55f70e152f63
Debugging the Docker container that died

In my case above, I forgot to close my code block with “}”. Thus, the container didn’t run. And that’s how you can use Docker in debug mode.

Leave a Reply

Your email address will not be published. Required fields are marked *