Read the Dockerfile: RUN versus CMD
QuizMediumAsked in: Capgemini, Swiggy
Read the Dockerfile.
Dockerfile
FROM python:3.12-slim WORKDIR /tests COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . . CMD ["pytest", "--junitxml=reports/junit.xml"]
Which statements are true? Choose all that apply.
- RUN pip install happens once, while the image is built
- CMD sets the default command when a container starts; docker run shop-tests pytest -m smoke replaces it
- Copying requirements.txt before the rest lets Docker reuse the installed packages when only test files change
- CMD runs during docker build
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.