github.com/pwn-term/docker@v0.0.0-20210616085119-6e977cce2565/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  > **Note**
    29  >
    30  > This command is only functional for containers that are started with the
    31  > `json-file` or `journald` logging driver.
    32  
    33  For more information about selecting and configuring logging drivers, refer to
    34  [Configure logging drivers](https://docs.docker.com/config/containers/logging/configure/).
    35  
    36  The `docker logs --follow` command will continue streaming the new output from
    37  the container's `STDOUT` and `STDERR`.
    38  
    39  Passing a negative number or a non-integer to `--tail` is invalid and the
    40  value is set to `all` in that case.
    41  
    42  The `docker logs --timestamps` command will add an [RFC3339Nano timestamp](https://golang.org/pkg/time/#pkg-constants)
    43  , for example `2014-09-16T06:17:46.000000000Z`, to each
    44  log entry. To ensure that the timestamps are aligned the
    45  nano-second part of the timestamp will be padded with zero when necessary.
    46  
    47  The `docker logs --details` command will add on extra attributes, such as
    48  environment variables and labels, provided to `--log-opt` when creating the
    49  container.
    50  
    51  The `--since` option shows only the container logs generated after
    52  a given date. You can specify the date as an RFC 3339 date, a UNIX
    53  timestamp, or a Go duration string (e.g. `1m30s`, `3h`). Besides RFC3339 date
    54  format you may also use RFC3339Nano, `2006-01-02T15:04:05`,
    55  `2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
    56  timezone on the client will be used if you do not provide either a `Z` or a
    57  `+-00:00` timezone offset at the end of the timestamp. When providing Unix
    58  timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
    59  that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
    60  seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
    61  fraction of a second no more than nine digits long. You can combine the
    62  `--since` option with either or both of the `--follow` or `--tail` options.
    63  
    64  ## Examples
    65  
    66  ### Retrieve logs until a specific point in time
    67  
    68  In order to retrieve logs before a specific point in time, run:
    69  
    70  ```bash
    71  $ docker run --name test -d busybox sh -c "while true; do $(echo date); sleep 1; done"
    72  $ date
    73  Tue 14 Nov 2017 16:40:00 CET
    74  $ docker logs -f --until=2s test
    75  Tue 14 Nov 2017 16:40:00 CET
    76  Tue 14 Nov 2017 16:40:01 CET
    77  Tue 14 Nov 2017 16:40:02 CET
    78  ```