📅  最后修改于: 2023-12-03 14:40:49.321000             🧑  作者: Mango
Docker Logs is a useful command-line tool for viewing logs generated by Docker containers. It allows developers and system administrators to track the output and debugging information produced by containerized applications. By monitoring logs, you can easily troubleshoot issues, analyze container behavior, and gain insight into the application's runtime activities.
The basic usage of the docker logs
command is as follows:
docker logs [OPTIONS] CONTAINER
Here are some commonly used options for the docker logs
command:
-f, --follow
: This option enables real-time log streaming. It continuously displays new log output as it is generated.--tail
: Use this option to view only a specific number of lines from the end of the logs. For example, --tail 100
will display the last 100 lines.--since
: View logs since a specified timestamp. You can provide a relative time like 10m
for the past 10 minutes or an absolute time in the format YYYY-MM-DDTHH:MM:SS
.--until
: View logs until a specified timestamp. Similar to --since
, you can provide relative or absolute timestamps.docker logs my-container
docker logs -f my-container
docker logs --tail 50 my-container
docker logs --since 2021-01-01T00:00:00 my-container
docker logs --since 2021-01-01T00:00:00 --until 2021-01-02T00:00:00 my-container
To format code snippets in Markdown, you can use triple backticks (```) with the appropriate language identifier. For example:
```bash
docker logs my-container
This renders as:
```bash
docker logs my-container
Make sure to replace the language identifier, bash
in this case, with the relevant language for your code snippet.