Docker Project for DevOps Engineers
Welcome to Day 17 of the #90DaysOfDevOps challenge! Today, we dive into an exciting hands-on project to showcase Docker’s capabilities. We will work with two applications: a Django Notes App and a Node.js To-Do App. Let's get started! 🚀
What is a Dockerfile?
A Dockerfile is a script that contains a set of instructions to build a Docker container. It defines the base image, dependencies, working directory, ports, and the command to run the application. For more details, check out this guide.
Project 1: Python (Django Notes App)
Steps:
1. Clone the Repository:
git clone -b dev https://github.com/LondheShubham153/django-notes-app.git
cd django-notes-app
2. Create a Dockerfile:
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
3. Build and Run the Container:
docker build -t django-notes-app .
docker run -d -p 8000:8000 django-notes-app
4. Access the Application:
Visit http://localhost:8000
in your browser to access the Django Notes App.
Tip: Stop and remove the running container before proceeding to the second project to avoid port conflicts.
Project 2: Node.js (To-Do App)
Steps:
1. Clone the Repository:
git clone -b LondheShubham153-patch-1 https://github.com/LondheShubham153/node-todo-cicd.git
cd node-todo-cicd
2. Create a Dockerfile:
FROM node:12.2.0-alpine
WORKDIR /app
COPY . /app
RUN npm install
EXPOSE 8000
CMD ["node", "app.js"]
3. Build and Run the Container:
docker build -t node-todo-app .
docker run -d -p 8000:8000 node-todo-app
4. Access the Application:
Visit http://localhost:8000
in your browser to access the Node.js To-Do App.
Pushing Images to Docker Hub
1. Log in to Docker Hub:
docker login
Provide your Docker Hub credentials when prompted.
2. Tag and Push the Images:
Django Notes App:
docker tag django-notes-app yourusername/django-notes-app:latest
docker push yourusername/django-notes-app:latest
Node.js To-Do App:
docker tag node-todo-app yourusername/node-todo-app:latest
docker push yourusername/node-todo-app:latest
Resources:
Conclusion
This project demonstrates the simplicity and power of Docker for containerizing applications. Whether it's a Python-based Django app or a Node.js To-Do app, Docker streamlines the process of setting up and running your projects.
Feel free to connect and share your progress on LinkedIn. Let’s keep the #90DaysOfDevOps momentum going!