Docker - logs of a container

> Virtualization - (Virtual Machine|Container) > Docker

1 - About

Fetch the logs of a container (ie the console)


3 - Syntax

3.1 - Docker


Fetch the logs of a container


      --details        Show extra details provided to logs
  -f, --follow         Follow log output
      --help           Print usage
      --since string   Show logs since timestamp
      --tail string    Number of lines to show from the end of the logs (default "all")
  -t, --timestamps     Show timestamps

The -f flag causes the docker logs command to act like the tail -f command and watch the container’s standard output.

3.2 - docker-compose

docker-compose logs --tail="10" -f Service

4 - Example

4.1 - Tail

Log tail of the last 10 line with timestamp

docker logs -f --tail 10 -t oraclexe
2017-08-15T19:55:55.936278872Z       ALTER DATABASE DROP LOGFILE GROUP 2
2017-08-15T19:55:55.936282823Z Deleted Oracle managed file /u01/app/oracle/fast_recovery_area/XE/onlinelog/o1_mf_2_ds6nf76r_.log
2017-08-15T19:55:55.936286695Z Completed:       ALTER DATABASE DROP LOGFILE GROUP 2
2017-08-15T19:55:55.936290401Z Cleared LOG_ARCHIVE_DEST_1 parameter default value
2017-08-15T19:55:55.936294553Z Using LOG_ARCHIVE_DEST_1 parameter default value as /u01/app/oracle/product/11.2.0/xe/dbs/arch
2017-08-15T19:55:55.936298289Z ALTER SYSTEM SET db_recovery_file_dest='' SCOPE=BOTH;
2017-08-15T20:00:50.667463276Z Tue Aug 15 20:00:50 2017
2017-08-15T20:00:50.667535991Z Starting background process SMCO
2017-08-15T20:00:50.667555809Z Tue Aug 15 20:00:50 2017
2017-08-15T20:00:50.667639899Z SMCO started with pid=27, OS id=832