Docker Project for DevOps Engineers

Docker Project for DevOps Engineers

  • Create a Dockerfile for a simple web application (e.g. a Node.js or Python app)

  • Build the image using the Dockerfile and run the container

  • Verify that the application is working as expected by accessing it in a web browser

  • Push the image to a public or private repository (e.g. Docker Hub)


Steps to set up the Project:

  • Install Git

  • Install Docker engine

  • Make a directory for your project

  • Clone GitHub repository

Docker File of our application

Breakdown of Dockerfile:

  • This line sets the base image to Python 3.11

  • Sets the working directory inside the container to /app.

  • It will copy all the source code from the local to the container

  • It will update pip and install the required dependencies.

  • The command used to run the app.

Build Docket image from Dockerfile

  • Building a Docker image is a crucial step in containerizing your Flask application.

  • It involves packaging your application and its dependencies into a single, portable image.

  • To build the Docker image, open a terminal and navigate to the directory containing your Dockerfile and application code.

Execute the following command:
1.

2.

Run the Docker image as a container

  • Once you have successfully built your Docker image, the next step is to run it as a container.

  • This involves creating an instance of your image, a runnable environment for your Flask application.

  • Execute the following command in the terminal:

Run the Flask Application on the browser

API Response

Stop Container:

Delete Container:

Push the Docker image to Docker Hub

  • Log in to Docker Hub and create a repository

  • Use the below command to log in on the Ubuntu machine, from where you have to push the image on Docker Hub and provide your username and password.

  • Run below command to push the image