While troubleshooting a production stack that was started with docker compose up -d, you need to watch the log output for the service named api. Which single command will show the last 150 log lines, continue streaming new entries in real time, and strip ANSI color codes from the output?
Using docker compose logs targets services defined in the Compose file, so specifying api restricts the output to that service. The --no-color switch removes ANSI colors, -f (or --follow) keeps the stream open for real-time monitoring, and --tail 150 limits the initial dump to the last 150 lines. The other commands fail to meet at least one requirement:
docker logs ... addresses containers, not Compose services, and the example shown passes an invalid --since 150 argument rather than limiting lines.
Omitting the service name streams logs for all services, not just api.
Using --tail 0 meets the color and follow requirements but shows no initial lines, so you would not see the last 150 entries you need.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is the difference between `docker logs` and `docker compose logs`?
Open an interactive chat with Bash
What does the `--tail 150` option do in the chosen command?
Open an interactive chat with Bash
Why is the `--no-color` switch necessary in some cases?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access