

The docker logs command also offers an array of convenient options, such as filtering output based on time and displaying timestamps. You can use the short form of the option -f, similar to the tail command, too. $ docker logs -follow testĪfter printing all of the container output so far, the command will continue to follow the logs. There’s a command line option with an appropriate name for that: run docker logs with –follow. This will still send all of the output generated so far through less, so you’ll need to page through to get to the end.īut sometimes you want to follow the logs as the container is running. If there’s too much output for a single screen, pipe it to a buffering command like less. This command displays all of the output the container has generated so far.

Start the container and then display the logs. So the easiest way to view container logs is with the docker logs command.

It executes a minimal Docker container with a Bourne shell script that logs a timestamp once every second. This command is an example from the Docker website. $ docker run -name test -d busybox sh -c "while true do $(echo date) sleep 1 done" We’ll create one that prints a message every second.
