.TH "DOCKER" "1" "Feb 2021" "Docker Community" "" .nh .ad l .SH NAME .PP docker\-container\-logs \- Fetch the logs of a container .SH SYNOPSIS .PP \fBdocker container logs [OPTIONS] CONTAINER\fP .SH DESCRIPTION .PP The \fBdocker container logs\fP command batch\-retrieves whatever logs are present for a container at the time of execution. This does not guarantee execution order when combined with a docker run (i.e., your run may not have generated any logs at the time you execute docker container logs). .PP The \fBdocker container logs \-\-follow\fP command combines commands \fBdocker container logs\fP and \fBdocker attach\fP\&. It will first return all logs from the beginning and then continue streaming new output from the container's stdout and stderr. .PP \fBWarning\fP: This command works only for the \fBjson\-file\fP or \fBjournald\fP logging drivers. .PP The \fB\fC\-\-since\fR and \fB\fC\-\-until\fR options can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. \fB\fC10m\fR, \fB\fC1h30m\fR) computed relative to the client machine's time. Supported formats for date formatted time stamps include RFC3339Nano, RFC3339, \fB\fC2006\-01\-02T15:04:05\fR, \fB\fC2006\-01\-02T15:04:05.999999999\fR, \fB\fC2006\-01\-02Z07:00\fR, and \fB\fC2006\-01\-02\fR\&. The local timezone on the client will be used if you do not provide either a \fB\fCZ\fR or a \fB\fC+\-00:00\fR timezone offset at the end of the timestamp. When providing Unix timestamps enter seconds[.nanoseconds], where seconds is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a fraction of a second no more than nine digits long. You can combine the \fB\fC\-\-since\fR or \fB\fC\-\-until\fR options with either or both of the \fB\fC\-\-follow\fR or \fB\fC\-\-tail\fR options. .PP The \fB\fCdocker container logs \-\-details\fR command will add on extra attributes, such as environment variables and labels, provided to \fB\fC\-\-log\-opt\fR when creating the container. .PP In order to retrieve logs before a specific point in time, run: .PP .RS .nf $ docker run \-\-name test \-d busybox sh \-c "while true; do $(echo date); sleep 1; done" $ date Tue 14 Nov 2017 16:40:00 CET $ docker logs \-f \-\-until=2s Tue 14 Nov 2017 16:40:00 CET Tue 14 Nov 2017 16:40:01 CET Tue 14 Nov 2017 16:40:02 CET .fi .RE .SH OPTIONS .PP \fB\-\-details\fP[=false] Show extra details provided to logs .PP \fB\-f\fP, \fB\-\-follow\fP[=false] Follow log output .PP \fB\-h\fP, \fB\-\-help\fP[=false] help for logs .PP \fB\-\-since\fP="" Show logs since timestamp (e.g. 2013\-01\-02T13:23:37) or relative (e.g. 42m for 42 minutes) .PP \fB\-\-tail\fP="all" Number of lines to show from the end of the logs .PP \fB\-t\fP, \fB\-\-timestamps\fP[=false] Show timestamps .PP \fB\-\-until\fP="" Show logs before a timestamp (e.g. 2013\-01\-02T13:23:37) or relative (e.g. 42m for 42 minutes) .SH SEE ALSO .PP \fBdocker\-container(1)\fP