

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Docker Logs
incomplete
2: Stats
incomplete
3: Top
incomplete
4: Resource Limits
incomplete
This lesson's interactive features are locked, please to keep using them
When containers are running in detached mode with the -d flag, you don't see any output in your terminal, which is nice for keeping your terminal clean, but what if something goes wrong?
Enter the docker logs command.
docker logs [OPTIONS] CONTAINER
# CONTAINER can be an id or name
docker run -d --name logdate alpine sh -c 'while true; do echo "LOGGING: $(date)"; sleep 1; done'
The sh -c 'while true; do echo "LOGGING: $(date)"; sleep 1; done' part is just a simple shell script to execute inside the container that prints the current date and time every second.
Notice that if you run docker logs over and over again, you will get different output. That's because you're only getting the most recent logs each time.
docker logs --tail 5 CONTAINER
Run and submit the CLI tests, then stop and remove the container.