github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/container_logs.md (about) 1 # logs 2 3 <!---MARKER_GEN_START--> 4 Fetch the logs of a container 5 6 ### Aliases 7 8 `docker container logs`, `docker logs` 9 10 ### Options 11 12 | Name | Type | Default | Description | 13 |:---------------------|:---------|:--------|:---------------------------------------------------------------------------------------------------| 14 | `--details` | | | Show extra details provided to logs | 15 | `-f`, `--follow` | | | Follow log output | 16 | `--since` | `string` | | Show logs since timestamp (e.g. `2013-01-02T13:23:37Z`) or relative (e.g. `42m` for 42 minutes) | 17 | `-n`, `--tail` | `string` | `all` | Number of lines to show from the end of the logs | 18 | `-t`, `--timestamps` | | | Show timestamps | 19 | [`--until`](#until) | `string` | | Show logs before a timestamp (e.g. `2013-01-02T13:23:37Z`) or relative (e.g. `42m` for 42 minutes) | 20 21 22 <!---MARKER_GEN_END--> 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://pkg.go.dev/time#RFC3339Nano) 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 ```