github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/docs/reference/commandline/logs.md (about) 1 --- 2 title: "logs" 3 description: "The logs command description and usage" 4 keywords: "logs, retrieve, docker" 5 --- 6 7 # logs 8 9 ```markdown 10 Usage: docker logs [OPTIONS] CONTAINER 11 12 Fetch the logs of a container 13 14 Options: 15 --details Show extra details provided to logs 16 -f, --follow Follow log output 17 --help Print usage 18 --since string Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes) 19 --until string Show logs before timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes) 20 -n, --tail string Number of lines to show from the end of the logs (default "all") 21 -t, --timestamps Show timestamps 22 ``` 23 24 ## Description 25 26 The `docker logs` command batch-retrieves logs present at the time of execution. 27 28 For more information about selecting and configuring logging drivers, refer to 29 [Configure logging drivers](https://docs.docker.com/config/containers/logging/configure/). 30 31 The `docker logs --follow` command will continue streaming the new output from 32 the container's `STDOUT` and `STDERR`. 33 34 Passing a negative number or a non-integer to `--tail` is invalid and the 35 value is set to `all` in that case. 36 37 The `docker logs --timestamps` command will add an [RFC3339Nano timestamp](https://golang.org/pkg/time/#pkg-constants) 38 , for example `2014-09-16T06:17:46.000000000Z`, to each 39 log entry. To ensure that the timestamps are aligned the 40 nano-second part of the timestamp will be padded with zero when necessary. 41 42 The `docker logs --details` command will add on extra attributes, such as 43 environment variables and labels, provided to `--log-opt` when creating the 44 container. 45 46 The `--since` option shows only the container logs generated after 47 a given date. You can specify the date as an RFC 3339 date, a UNIX 48 timestamp, or a Go duration string (e.g. `1m30s`, `3h`). Besides RFC3339 date 49 format you may also use RFC3339Nano, `2006-01-02T15:04:05`, 50 `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local 51 timezone on the client will be used if you do not provide either a `Z` or a 52 `+-00:00` timezone offset at the end of the timestamp. When providing Unix 53 timestamps enter seconds[.nanoseconds], where seconds is the number of seconds 54 that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap 55 seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a 56 fraction of a second no more than nine digits long. You can combine the 57 `--since` option with either or both of the `--follow` or `--tail` options. 58 59 ## Examples 60 61 ### <a name="until"></a> Retrieve logs until a specific point in time (--until) 62 63 In order to retrieve logs before a specific point in time, run: 64 65 ```console 66 $ docker run --name test -d busybox sh -c "while true; do $(echo date); sleep 1; done" 67 $ date 68 Tue 14 Nov 2017 16:40:00 CET 69 $ docker logs -f --until=2s test 70 Tue 14 Nov 2017 16:40:00 CET 71 Tue 14 Nov 2017 16:40:01 CET 72 Tue 14 Nov 2017 16:40:02 CET 73 ```