Table of contents
- <mark>Dockerfile:</mark>
- <mark>React-Django App Project:</mark>
- <mark>Steps:</mark>
- Build the image using the Dockerfile and run the container
- <mark>Verify that the application is working as expected by accessing it in a web browser:</mark>
- <mark>Dockerhub push image:</mark>
- <mark>docker login(userid/password)</mark>
Dockerfile:
Docker is a tool that makes it easy to run applications in containers. Containers are like small packages that hold everything an application needs to run. To create these containers, developers use something called a Dockerfile.
A Dockerfile is like a set of instructions for making a container. It tells Docker what base image to use, what commands to run, and what files to include. For example, if you were making a container for a website, the Dockerfile might tell Docker to use an official web server image, copy the files for your website into the container, and start the web server when the container starts.
Here are all the commands that we can use in the Dockerfile.
Comments
FROM
CMD
ENTRYPOINT
WORKDIR
ENV
COPY
LABEL
RUN
ADD
.dockerignore
ARG
EXPOSE
USER
VOLUME
React-Django App Project:
Create a Dockerfile for a simple web application (e.g. a Node.js or Python app)
Steps:
Create EC2 instance
Check if docker is available on server-systemctl status docker
Install docker -install apt-get docker.io && sudo apt-get update
check user by echo $USER
Add user to give access so that we do not need to give sudo for every command
sudo usermod -a -G docker $USER
Reboot after adding user
Sudo reboot
clone git repo url-git clone urlname---for requirements
Create Dockerfile for Python Django:
Check what tools/and requirements by doing cat requirements.txt and READMD file.
FROM:For the base image,This command must be on top of the docker file/
COPY:Copy files from local system(docker VM) we need to provide source/destination(we cant download the file from internet and any remote Repo)
RUN:To execute commands,it will create layer in image.
CMD:Execute command but during container creation.
Create docker file:
Build the image using the Dockerfile and run the container
docker build . -t react-django-app:latest
docker run -d -p 8000:8000 react-django-app:latest
Make sure port added in EC2 instance under inbound security.
Docker images:
Verify that the application is working as expected by accessing it in a web browser:
Give public IP address with port number and check if application is working as expected.
Dockerhub push image:
docker login(userid/password)
tag react-django-app:latest gajananbarure/react-django-app
docker images docker push gajananbarure/react-django-app docker images
docker tag python:3.9 gajananbarure/python docker push gajananbarure/python
Push the image to a public or private repository (e.g. Docker Hub )
Dockerhub---docker pull gajananbarure/react-django-app
Conclusion:This project is based on python,django so, have used python 3:9 version in this project and related files.I have done analysis on requirements.txt file and also checked os/versions of respective software by using this file and written dockerfile to execute this project,Basically this project is designed to add the tasks in this app like todo tasks for day to day life.
Thank you for reading!! Hope you find this helpful.
#day17#90daysofdevops#devopscommunity#
Always open for suggestions..!!
Thankyou Shubham Londhe !!