# DevOps90DaysChalleneg # Hi ðthere, # Now we are on the Day 17 task # **Docker for DevOps Engineers** Checkout the below link for Day 17 task: [https://github.com/LondheShubham153/90DaysOfDevOps/blob/master/2023/day17/tasks.md](https://github.com/LondheShubham153/90DaysOfDevOps/blob/master/2023/day17/tasks.md) For this, you first need an AWS EC2 instance of your own choice. Here is my blog on creating an AWS EC2 instance : Checkout the below link for Provisioning your first EC2 Instance [https://progressivecoder.com/step-by-step-process-to-launch-aws-ec2-instance/](https://progressivecoder.com/step-by-step-process-to-launch-aws-ec2-instance/) Once you are done with creating an EC2 instance you need to SSH into it. Now you need to install the docker Engine in your server. Checkout the below link [https://www.zehncloud.com/how-to-install-docker-on-amazon-ec2-instance/](https://www.zehncloud.com/how-to-install-docker-on-amazon-ec2-instance/) Below are the steps that we will be going to perform in the process: 1. Install Git and clone the repo of the react-python Django web application 2. Install Docker 3. Create and configure a Dockerfile 4. Build a Docker image 5. Create and run a Docker container 6. Access it # **Install git and Clone the repo of the Python Django application** Open the instance, first, you need to install Git in it so that we can clone the application repository from GitHub(VCS). Use command : ```bash sudo apt install git ``` ```bash git clone https://github.com/sandhya261996/react_django_demo_app.git ```   # **2\. Install Docker** Install Docker in the machine using the command : ```bash sudo apt install docker -y ```  Now check the version of the docker and start the docker and check the status of the docker to know if it is running using the below commands : ```bash docker -v systemctl start docker systemctl status docker ```  # **3\. Create and configure a Dockerfile** Now we will create and configure a docker file as per the requirement of the Node.js application. Change the directory to the cloned project and create Dockerfile there. ```bash FROM python:3.9 WORKDIR app COPY . /app RUN pip install -r requirements.txt EXPOSE 8000 CMD ["python", "manage.py","runserver","0.0.0.0:8000"] ```  # **4\. Build a Docker image** Now before starting the build process check if there is any existing container running with the same name. ```bash sudo docker ps sudo docker ps -a ```  # **5\. Create and run a Docker container** Using the image that has been built we will create a container out of it and run it: Use the below commands : ```bash sudo docker run -d --name python-django-app -p 8000:8000 django_app:latest ``` You can see a container running here that can be accessed on port 8000 as we have done the port mapping on port 8000. # **6\. Access it** Now you can take the public IP of the machine and port 8000 to access the application.  # **7\. Pushing the image on DockerHub** We have already created a Docker image using the Dockerfile. Check all the images present by using the command. ```bash sudo docker images ``` Now we will log in in to the DockerHub by adding the command: ```bash sudo Docker login ``` Put your username and password here. If the login is successful, then you will get a message like **Login Succeeded**.  Now tag the locally created image to the docker hub. This means we have to tag the image with the docker hub username. ```bash sudo docker tag django_app:latest sandhyakumari1996/django_app:latest ```  Now push the image to the Docker hub using the push command. ```bash sudo docker push sandhyakumari1996/djnago_app:latest ```  When it is done, you can check in your Docker hub if it is pushed.  **Please, feel free to drop any questions in the comments below. I would be happy to answer them.** **If you find this post helpfulðð, please follow and click the heartâ¤â¤ button below to show your support.** **\_ Thank you for reading** **\_sandhya kumari**