Docker Logs Tail-Docker Logs To File-Docker Logs Tutorial

Docker Logs Tail-Docker Logs To File-Docker Logs Tutorial

to troubleshoot or debug we need the logs of docker container. docker logs command is used to print the logs of any container. in the following steps i will show you how to find the logs of docker container and how to get or tail last N logs of a container with docker logs tail command. in the following commands i will use docker container id you can use either container id or container name.

find Docker Container Logs file Location


so you can abserve from above commands that logfile of a container is located in


find the logs of docker container

it will show you all the logs of docker container

docker container logs with timestamp

it will Show you the Docker container logs with timestamps: that means it will show you each log with at what time it generated.

find docker container logs since particular date:


find Docker container logs since particular time

Ex: find Docker logs since 1 pm:

  docker logs container_id  –since  2019-02-12T13:00

it will show you the logs of a container which are generated after 2019 feb 2 – 1pm

Tail the last N lines of logs:

with docker logs tail command we can view the last N logs of a container.

it will print last N logs of docker container.

if you want to print last 100 logs of docker container use

docker logs container_id –tail 100

follow the docker container logs (or)To see live logs

use or test the feature of your container and it will sent the logs to above command so you can view the logs at a time when you are accessing the container. 

docker logs to file

all the logs of every docker container is stored in  /var/lib/docker/containers/container_id/container_id-json.log

if you want to copy the docker  logs to file or docker logs to stdout use below command.

docker logs to stdout

docker logs container > /tmp/stdout.log

docker logs stderr

by using below command you can copy the docker container logs stderr to any file

docker logs container 2> /tmp/stdout.log



  • docker logs location
  • docker logs tail  
  • docker logs to file 
  • docker logs clear 
  • docker logs stderr 
  • docker logs to stdout 

Do You Want To Become An Expert in Devops?
                                    Subscribe To DecodingDevops
                                Get New Posts To your mail Inbox

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

Decoding DevOps will use the information you provide on this form to be in touch with you and to provide updates and marketing.