Table of Contents
How to see docker container logs
Introduction
In this tutorial, I will list out various commands to display logs
To see docker containers logs make sure that first of all, docker container is running you can check this by using
1 2 3 | docker ps -a |
Once you have confirmed that docker container is up and running you can use following commands
To see all the logs of a particular container
123docker logs ContainerName/ContainerIDTo follow docker log output or tail continuously
123docker logs --follow ContainerName/ContainerIDTo see last n lines of logs
In this case, last 2500 lines will be displayed
123docker logs --tail 2500 ContainerName/ContainerIDTo see logs since particular date or timestamp
First get the Timestamp format in logs using
123docker logs --timestamps ContainerName/ContainerIDNow use the timestamp which should be in format like this 2017-05-03T10:00:59.935397007Z and use it to display logs
For e.g if only a day’s log needs to be viewed
123docker logs --since 2017-05-03 ContainerName/ContainerID
For e.g if only a day’s log needs to be viewed since 10 am123docker logs --since 2017-05-03T10:00 ContainerName/ContainerID