I am new to CICD trying to understand docker.
While deploying Django app using jenkins pipeline which is calling dockerfile to build docker image. The dockerfile calls runner.sh which have below line of code :
uwsgi --http "0.0.0.0:${PORT}" --module my_proj.wsgi --master --processes 4 --threads 2
Everything is working fine, but i curious to know why this code not run application while building docker image and running application when this image is being run on host server.
I tried running application in dockerfile in that case while deploying jenkins pipeline get stuck as it run the application and keep as stuck as application will keep on running while building image.
, but i curious to know why this code not run application while building docker image and running application when this image is being run on host server.
I assume runner.sh
is pointed as ENTRYPOINT
in your docker image. The purpose of ENTRYPOINT is to execute commands/scripts during running state of the docker image.
Then the question is why it is being executed in run state rather than the build state. It is because this command has nothing to do with building the docker environment. Rather this command runs your application. This process will not stop until it is explicitly forced to stop (like by using ctrl+c). Thus if you put this command in build state, ie using RUN ...
in Dockerfile, it will not finish building because the command keeps on running.
I tried running application in dockerfile in that case while deploying jenkins pipeline get stuck as it run the application and keep as stuck as application will keep on running while building image.
Regarding that, the purpose of you Jenkins pipeline is to build the docker image, send the image binary to the deployment environment, where this image will be in executable state. Hence it is not a good idea to put this command in build state of the dockerfile.