Day17 of #90DaysOfDevOps Challenge
Aishwarya keshri
Azure DevOps Support Engineer at Microsoft || MS Certified - AZ900 || Ex-Onclusive || NIT Raipur
Dockerfile:
Instead of manually creating docker images by running multiple commands one by one, we can write a script where we can specify everything required for our image, and run one command to build the whole image.
Each command in dockerfile adds layers to create a docker image.
Here are some of the most commonly used commands in a Dockerfile:
Tasks:
Python application cloned: https://github.com/shreys7/django-todo
The steps to run the application locally are explained in the above link. I am just creating the dockerfile for the same steps.
Dockerfile:
FROM python:3
RUN pip install Django==4.2.2
COPY . .
RUN python manage.py migrate
CMD ["python", "manage.py", "runserver", "0.0.0.0:8005"]
2. Build the image using the Dockerfile and run the container.
Build the image -
docker build . -t todo-app
Run the Container -
3. Verify that the application is working as expected by accessing it in a web browser.
4. Push the image to a public or private repository (e.g. Docker Hub ).
Firstly, I renamed the image to push in my docker hub repo.
sudo docker tag old:tag new:tag
Now, while pushing I got access denied so I first logged in and then pushed the image.
sudo docker login
sudo docker push imagename
The image is successfully pushed.
Thank you for reading! ??