diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/docker/engine%2Freference%2Fcommandline%2Flogs%2Findex.html | |
new repository
Diffstat (limited to 'devdocs/docker/engine%2Freference%2Fcommandline%2Flogs%2Findex.html')
| -rw-r--r-- | devdocs/docker/engine%2Freference%2Fcommandline%2Flogs%2Findex.html | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/devdocs/docker/engine%2Freference%2Fcommandline%2Flogs%2Findex.html b/devdocs/docker/engine%2Freference%2Fcommandline%2Flogs%2Findex.html new file mode 100644 index 00000000..0600b331 --- /dev/null +++ b/devdocs/docker/engine%2Freference%2Fcommandline%2Flogs%2Findex.html @@ -0,0 +1,20 @@ +<h1>docker logs</h1> <p><br></p> <p>Fetch the logs of a container</p> <h2 id="usage">Usage</h2> <div class="highlight"><pre class="highlight" data-language="">$ docker logs [OPTIONS] CONTAINER +</pre></div> <p>Refer to the <a href="#options">options section</a> for an overview of available <a href="#options"><code class="language-plaintext highlighter-rouge">OPTIONS</code></a> for this command.</p> <h2 id="description">Description</h2> <p name="extended-description">The <code class="language-plaintext highlighter-rouge">docker logs</code> command batch-retrieves logs present at the time of execution.</p> <blockquote> <p><strong>Note</strong></p> <p>This command is only functional for containers that are started with the <code class="language-plaintext highlighter-rouge">json-file</code> or <code class="language-plaintext highlighter-rouge">journald</code> logging driver.</p> </blockquote> <p>For more information about selecting and configuring logging drivers, refer to <a href="https://docs.docker.com/config/containers/logging/configure/">Configure logging drivers</a>.</p> <p>The <code class="language-plaintext highlighter-rouge">docker logs --follow</code> command will continue streaming the new output from the container’s <code class="language-plaintext highlighter-rouge">STDOUT</code> and <code class="language-plaintext highlighter-rouge">STDERR</code>.</p> <p>Passing a negative number or a non-integer to <code class="language-plaintext highlighter-rouge">--tail</code> is invalid and the value is set to <code class="language-plaintext highlighter-rouge">all</code> in that case.</p> <p>The <code class="language-plaintext highlighter-rouge">docker logs --timestamps</code> command will add an <a href="https://golang.org/pkg/time/#pkg-constants">RFC3339Nano timestamp</a> , for example <code class="language-plaintext highlighter-rouge">2014-09-16T06:17:46.000000000Z</code>, to each log entry. To ensure that the timestamps are aligned the nano-second part of the timestamp will be padded with zero when necessary.</p> <p>The <code class="language-plaintext highlighter-rouge">docker logs --details</code> command will add on extra attributes, such as environment variables and labels, provided to <code class="language-plaintext highlighter-rouge">--log-opt</code> when creating the container.</p> <p>The <code class="language-plaintext highlighter-rouge">--since</code> option shows only the container logs generated after a given date. You can specify the date as an RFC 3339 date, a UNIX timestamp, or a Go duration string (e.g. <code class="language-plaintext highlighter-rouge">1m30s</code>, <code class="language-plaintext highlighter-rouge">3h</code>). Besides RFC3339 date format you may also use RFC3339Nano, <code class="language-plaintext highlighter-rouge">2006-01-02T15:04:05</code>, <code class="language-plaintext highlighter-rouge">2006-01-02T15:04:05.999999999</code>, <code class="language-plaintext highlighter-rouge">2006-01-02Z07:00</code>, and <code class="language-plaintext highlighter-rouge">2006-01-02</code>. The local timezone on the client will be used if you do not provide either a <code class="language-plaintext highlighter-rouge">Z</code> or a <code class="language-plaintext highlighter-rouge">+-00:00</code> 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 <code class="language-plaintext highlighter-rouge">--since</code> option with either or both of the <code class="language-plaintext highlighter-rouge">--follow</code> or <code class="language-plaintext highlighter-rouge">--tail</code> options.</p> <p>For example uses of this command, refer to the <a href="#examples">examples section</a> below.</p> <h2 id="options">Options</h2> <table> <thead> <tr> <td>Name, shorthand</td> <td>Default</td> <td>Description</td> </tr> </thead> <tbody> <tr> <td><code class="language-plaintext highlighter-rouge">--details</code></td> <td></td> <td>Show extra details provided to logs</td> </tr> <tr> <td> +<code class="language-plaintext highlighter-rouge">--follow</code> , <code class="language-plaintext highlighter-rouge">-f</code> +</td> <td></td> <td>Follow log output</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--since</code></td> <td></td> <td>Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)</td> </tr> <tr> <td> +<code class="language-plaintext highlighter-rouge">--tail</code> , <code class="language-plaintext highlighter-rouge">-n</code> +</td> <td><code class="language-plaintext highlighter-rouge">all</code></td> <td>Number of lines to show from the end of the logs</td> </tr> <tr> <td> +<code class="language-plaintext highlighter-rouge">--timestamps</code> , <code class="language-plaintext highlighter-rouge">-t</code> +</td> <td></td> <td>Show timestamps</td> </tr> <tr> <td><code class="language-plaintext highlighter-rouge">--until</code></td> <td></td> <td>Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)</td> </tr> </tbody> </table> <h2 id="examples">Examples</h2> <h3 id="retrieve-logs-until-a-specific-point-in-time">Retrieve logs until a specific point in time</h3> <p>In order to retrieve logs before a specific point in time, run:</p> <div class="highlight"><pre class="highlight" data-language="">$ 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 +</pre></div> <div class="_attribution"> + <p class="_attribution-p"> + © 2019 Docker, Inc.<br>Licensed under the Apache License, Version 2.0.<br>Docker and the Docker logo are trademarks or registered trademarks of Docker, Inc. in the United States and/or other countries.<br>Docker, Inc. and other parties may also have trademark rights in other terms used herein.<br> + <a href="https://docs.docker.com/engine/reference/commandline/logs/" class="_attribution-link">https://docs.docker.com/engine/reference/commandline/logs/</a> + </p> +</div> |
