Closed Rony-dot closed 1 year ago
You are correct that a container image can have only one defined CMD
. Therefore, when a second is specified, it replaces the previously defined value.
This case is a little different because the Dockerfile has multiple stages (the multiple FROM
statements). The first CMD
is for the stage named dev-env
while the second is for the final stage.
Why would you do something like this? There are times in which you might want to build or target a container image, but only end at a specific stage. This particular project isn't doing that at the moment though (which maybe it should!).
I do this quite often in development environments where an intermediate stage might be watching for code changes and rebuilding my app, while the final stage is production ready. Using this approach, you can have everything defined within a single Dockerfile. Make sense?
That makes sense ! Thank you for explaining this so well.
Why u start app in production instance like a developmen, with manage.py runserver? Need to use uwsgi or gunicorn for production.
Your dockerfile
https://github.com/docker/awesome-compose/blob/e3ea3e9044dcae2ed409665d29434fa53a5a2198/sparkjava-mysql/backend/Dockerfile#L25
https://github.com/docker/awesome-compose/blob/e3ea3e9044dcae2ed409665d29434fa53a5a2198/sparkjava-mysql/backend/Dockerfile#L31
Problem / Question: