This content originally appeared on DEV Community and was authored by Bhaskar Sharma
Hello dev.to community!
Yesterday, I explored GitHub Actions, GitHubβs native CI/CD tool that makes automation seamless.
Today, Iβm diving into Docker, the backbone of containerization in DevOps.
Why Docker Matters
Before Docker, apps often suffered from the classic βworks on my machineβ problem. Docker solves this by packaging applications with all dependencies into portable containers.
Consistent environment across dev, test, and prod
Lightweight and faster than virtual machines
Easy scaling with orchestration tools (like Kubernetes)
Huge ecosystem with Docker Hub images
Core Concepts in Docker
Image β Blueprint of your application (built using a Dockerfile)
Container β Running instance of an image
Dockerfile β Instructions to build an image
Registry β Storage for images (Docker Hub, ECR, GCR)
Volume β Persistent storage for containers
Network β Communication between containers
Example: Simple Dockerfile
Use Node.js base image
FROM node:18
Set working directory
WORKDIR /app
Copy package files and install dependencies
COPY package*.json ./
RUN npm install
Copy source code
COPY . .
Expose app port
EXPOSE 3000
Start the app
CMD [“npm”, “start”]
Build and run it:
docker build -t myapp .
docker run -p 3000:3000 myapp
DevOps Use Cases
Package applications for CI/CD pipelines
Deploy microservices on Kubernetes or ECS
Create reproducible environments for testing
Run security scans (e.g., Trivy) on container images
Pro Tips
Keep images small β use slim/alpine base images
Use .dockerignore to avoid unnecessary files in builds
Tag images properly (e.g., myapp:v1.0.0)
Scan images for vulnerabilities before pushing to registry
Hands-on Mini-Lab (Try this!)
1⃣ Install Docker Desktop
2⃣ Write a Dockerfile for your app
3⃣ Build and run the image locally
4⃣ Push it to Docker Hub with docker push
Key Takeaway
Docker makes applications portable, scalable, and easy to manage β a cornerstone skill for every DevOps engineer.
Tomorrow (Day 21):
Iβll explore Kubernetes β the orchestration layer that takes Docker to production scale.
#Docker #DevOps #Containers #Automation #SRE
This content originally appeared on DEV Community and was authored by Bhaskar Sharma