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...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .