Container Logs
Part of the Introduction to Docker section of Coddy's Terminal journey — lesson 17 of 40.
Whatever a container prints is captured by Docker, even after the container exits. You can read it back at any time with docker logs and the container's name:
docker run --name once alpine echo line-one
docker logs onceThe first command runs the container, which prints line-one. The second command replays that captured output from the container's log.
Logs are how you check what a background (detached) container has been doing without attaching to it.
Challenge
EasyRun an alpine container named printer that echoes saved message, then read its log back with docker logs.
Cheat sheet
Use docker logs <name> to read captured output from a container (even after it exits):
docker run --name once alpine echo line-one
docker logs onceTry it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.