Bird
0
0

What is the expected behavior when running:

medium📝 Command Output Q4 of 15
Docker - in CI/CD
What is the expected behavior when running:
docker run --rm -v $(pwd):/app -w /app python:3.12 pytest test_example.py
if test_example.py contains only passing tests?
ATests run successfully, output shows passing results, and container is removed
BTests fail due to missing dependencies, container remains running
CContainer starts but does not execute tests due to volume mount error
DTests run but container stays active after completion
Step-by-Step Solution
Solution:
  1. Step 1: Analyze command flags

    --rm removes container after exit; -v mounts current directory to /app; -w sets working directory; python:3.12 image runs pytest on test_example.py.
  2. Step 2: Consider test outcome

    Since tests pass, pytest exits with success, container stops and is removed due to --rm.
  3. Final Answer:

    Tests run successfully, output shows passing results, and container is removed -> Option A
  4. Quick Check:

    --rm removes container after successful test run [OK]
Quick Trick: --rm removes container after tests finish [OK]
Common Mistakes:
  • Assuming container stays running without -d
  • Thinking volume mount causes test failure
  • Believing tests fail without extra dependencies

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Docker Quizzes