docker logs

Read a container's output: why it crashed, who visited it, the last lines or live as it happens.

>_ Try it: a simulated Linux, right here
Loading the terminal…

Examples

  • docker logs site
  • docker logs --tail 1 site
  • docker logs -t site
  • docker logs site | grep GET
  • docker logs -f web

How it works

docker logs NAME shows everything the container printed: startup messages, requests, and the error when it crashes.

It works on stopped containers too, which makes it the first stop when something won't start.

Syntax

docker logs [OPTIONS] CONTAINER

Options

OptionWhat it does
--tail Nonly the last N lines
-tadd a timestamp to each line
-fkeep following new lines (Ctrl+C to stop)

Good to know

  • A container that exits at once? docker ps -a, then docker logs NAME: the reason is usually in the last lines.
  • Logs belong to the container: docker rm deletes them too.