The docker logs command
This command fetches the log of a container without logging in to the container. It batch-retrieves logs present at the time of execution. These logs are the output of stdout and stderr. The general usage is shown in docker logs [OPTIONS] CONTAINER
.
The -follow
option will continue to provide the output till the end, -t
will provide the timestamp, and --tail= <number of lines>
will show the number of lines of the log messages of your container:
$ sudo docker logs a245253db38b * Running on http://0.0.0.0:5000/ 172.17.42.1 - - [22/Mar/2015 06:04:23] "GET / HTTP/1.1" 200 - 172.17.42.1 - - [24/Mar/2015 13:43:32] "GET / HTTP/1.1" 200 - $ sudo docker logs -t a245253db38b 2015-03-22T05:03:16.866547111Z * Running on http://0.0.0.0:5000/ 2015-03-22T06:04:23.349691099Z 172.17.42.1 - - [22/Mar/2015 06:04:23] "GET / HTTP/1.1" 200 - 2015-03-24T13:43:32.754295010Z 172.17.42.1 - - [24/Mar/2015 13:43:32] "GET / HTTP/1.1" 200 -
We also used the docker logs
utility in Chapter...