.nh
.TH "DOCKER" "1" "Jun 2024" "Docker Community" "Docker User Manuals"

.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--since\fR and \fB--until\fR options can be Unix timestamps, date formatted timestamps,
or Go duration strings (e.g. \fB10m\fR, \fB1h30m\fR) computed relative to the client machine's
time. Supported formats for date formatted time stamps include RFC3339Nano,
RFC3339, \fB2006-01-02T15:04:05\fR, \fB2006-01-02T15:04:05.999999999\fR,
\fB2006-01-02Z07:00\fR, and \fB2006-01-02\fR\&. The local timezone on the client will be
used if you do not provide either a \fBZ\fR or a \fB+-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--since\fR or \fB--until\fR
options with either or both of the \fB--follow\fR or \fB--tail\fR options.

.PP
The \fBdocker container logs --details\fR command will add on extra attributes, such as
environment variables and labels, provided to \fB--log-opt\fR when creating the
container.

.PP
In order to retrieve logs before a specific point in time, run:

.EX
$ 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 test
Tue 14 Nov 2017 16:40:00 CET
Tue 14 Nov 2017 16:40:01 CET
Tue 14 Nov 2017 16:40:02 CET

.EE


.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:37Z") or relative (e.g. "42m" for 42 minutes)

.PP
\fB-n\fP, \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:37Z") or relative (e.g. "42m" for 42 minutes)


.SH SEE ALSO
.PP
\fBdocker-container(1)\fP
