Bird
0
0

Given this Dockerfile snippet:

medium📝 component behavior Q4 of 15
Django - Deployment and Production
Given this Dockerfile snippet:
FROM python:3.12-slim
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

What happens when you run this container?
AThe container fails because requirements.txt is missing
BThe Django app starts and listens on all network interfaces at port 8000
CThe app runs but only listens on localhost inside the container
DThe container builds but does not start the app
Step-by-Step Solution
Solution:
  1. Step 1: Analyze CMD instruction

    The CMD runs the Django development server binding to 0.0.0.0:8000, which means all interfaces inside the container.
  2. Step 2: Understand COPY and RUN steps

    Files are copied, dependencies installed, so the app can start properly.
  3. Final Answer:

    The Django app starts and listens on all network interfaces at port 8000 -> Option B
  4. Quick Check:

    CMD runs server on 0.0.0.0:8000 [OK]
Quick Trick: 0.0.0.0 binds server to all container interfaces [OK]
Common Mistakes:
MISTAKES
  • Assuming app listens only on localhost
  • Thinking container only builds but doesn't run
  • Believing requirements.txt is missing without evidence

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes