ENTRYPOINT vs CMD Scenario
Question
You have a Dockerfile with the following last two lines:
dockerfile
ENTRYPOINT ["python", "manage.py"]
CMD ["runserver"]
A junior engineer on your team runs docker run my-django-app migrate expecting to run database migrations. They report that the container exits immediately with an error. You inspect the Dockerfile and notice the ENTRYPOINT uses exec form. What command actually executed inside the container, and what is the most likely cause of the error?
Answer
The command that executed was python manage.py migrate. The ENTRYPOINT ["python", "manage.py"] is fixed; the argument migrate from docker run replaced the default CMD ["runserver"]. The error is most likely that the container lacks a database connection — migrate requires a running database, and the container was probably started without the correct environment variables or network access to the database service.
You're viewing a free demo lesson
Take the 4-min skill check to get your personalized roadmap, then sign up to save it.