Table of contents
No headings in the article.
Ok now, As a DevOps engineer, the first step I would take is I will basically to choose a base image so in this case I will choose a base image called ubuntu so if you want to try this same example and you can also try with centos and see that there will not any issue at all but the only thing is you have to modify this thing instead of apt-get you have to use yum for centos.
So now from ubuntu what I did is I chose a working directory so what is a working directory?
A working directory it's basically an identification of where your source code going to save let's say you have multiple projects in your organization and you have multiple people in your team whenever you are writing a docker file you can create a standard saying that we will always put the source code whenever we are containerization application in a folder called /app ok.
so it can be a standard that you can follow this is your work directory.
After that, if you have programming experience if you are containerization python applications you will definitely know that the first thing to copy inside your work directory is the requirment.txt file because the requiement.txt file where you have your python dependencies the dependencies required run your application that are Django and tzdata what I did I copied the requirement.txt file on to the working directory and then I copied the source code itself because you might have the dependencies but thing that you need to have source code itself using the source code and dependencies you will form a bundle and you will form the binary your application.
After that what I have done,I got the requirment.txt copied and I got the DevOps source code copied but if I tried to execute this one now at this point it's failed because this is an ubuntu base image or there no python here I will choose my base image ubuntu and I have installed python so if it's python base image you don't even have to install this base image .
Once installed python so just download the dependencies pip install -r requiements.txt && \ cd devops so ever configuration is done now.
so entry point and cmd command are your serve starting command
Entrypoint is something that you can not change so as a user whenever you are running the container let's say here we define python3 they can not overwrite your value in a docker image whereas cmd is something that is configurable for example here whenever running the container I am saying manage.py and running server and I am just changing IP address or port then that is a configurable field that you have passed a cmd. I can also pass python3 in this phase same thing only so I can simply ignore the entry point.
And you see here the application is build
if you do docker images you will see the images.
so docker run what I am going to do is I am going to run an interactive mode and map the port 8000:8000 on the container to host I am using the same port for mapping .