YouTip LogoYouTip

Docker Logs Command

# Docker logs Command [![Image 3: Docker Command Manual](#)Docker Command Manual](#) * * * The `docker logs` command is used to fetch and view the log output of a container. The `docker logs` command is very useful and can help users debug and monitor running containers. ### Syntax docker logs CONTAINER Common Options: * **`-f, --follow`**: Follow log output (similar to `tail -f`). * **`--since`**: Show logs since a specified time. * **`-t, --timestamps`**: Show log timestamps. * **`--tail`**: Only show the last part of the logs, e.g., `--tail 10` shows the last 10 lines. * **`--details`**: Show extra details provided to the logs. * **`--until`**: Show logs until a specified time. ### Examples **Display Container Logs** docker logs my_container Displays all logs for the container named my_container, with output like: hello world hello world hello world ... **Follow Log Output** docker logs -f my_container Continuously displays the log output for my_container, with output like: hello world hello world hello world ... **Display Logs with Timestamps** docker logs -t my_container Displays logs with timestamps, with output like: 2023-07-22T15:04:05.123456789Z hello world 2023-07-22T15:04:06.123456789Z hello world 2023-07-22T15:04:07.123456789Z hello world ... **Display Logs Since a Specified Time** docker logs --since="2023-07-22T15:00:00" my_container Displays logs after 2023-07-22T15:00:00. **Display the Last 10 Lines of Logs** docker logs --tail 10 my_container Displays the last 10 lines of logs for my_container. **Display Logs with Extra Details** docker logs --details my_container Displays logs for my_container, including extra details. **Display Logs Until a Specified Time** docker logs --until="2023-07-22T16:00:00" my_container Displays logs before 2023-07-22T16:00:00. * * Docker Command Manual](#)
← Docker Export CommandDocker Attach Command β†’