π Week 5: Docker Basics & Advanced Challenge


Welcome to my Week 5 Docker Challenge blog! π This week was all about diving into Docker fundamentals and advanced concepts. I explored containerization, built and optimized images, worked with Docker Hub, volumes, networks, Docker Compose, and even ran a security analysis using Docker Scout.
Below, Iβve documented all my tasks, steps, commands, and reflections.
Task 1: Introduction and Conceptual Understanding
Dockerβs Purpose in Modern DevOps
Docker is a powerful platform that simplifies application development, shipping, and deployment by using lightweight, portable containers. In modern DevOps, Docker bridges the gap between developers and operations, enabling consistent environments across local development, testing, and production.
Virtualization vs. Containerization
Virtualization: Runs multiple operating systems on a single physical server using hypervisors. Each VM is heavy because it includes a full OS.
Containerization: Shares the host OS kernel, running lightweight, isolated applications in containers. Containers start faster, consume fewer resources, and are ideal for microservices and CI/CD pipelines.
π Containerization is preferred for its speed, scalability, and portability.
Task 2: Create a Dockerfile for a Sample Project
I created a simple Node.js app that prints βHello, Docker!β.
Dockerfile:
# Use official Node.js image as base
FROM node:18-alpine
# Set working directory
WORKDIR /app
# Copy app files
COPY . .
# Install dependencies
RUN npm install
# Expose app port
EXPOSE 8080
# Run the app
CMD ["node", "index.js"]
Commands:
docker build -t vaishnavi/sample-app:latest .
docker run -d -p 8080:80 vaishnavi/sample-app:latest
docker ps
docker logs <container_id>
β Successfully verified the app running in the container.
Task 3: Explore Docker Terminologies and Components
Key Terms
Image: Blueprint of a container.
Container: Running instance of an image.
Dockerfile: Script to build Docker images.
Volume: Persistent storage outside container lifecycle.
Network: Enables communication between containers.
Docker Components
Docker Engine: Core runtime managing containers.
Docker CLI: Command-line tool to interact with Docker.
Docker Hub: Registry for sharing and storing images.
Docker Daemon: Runs in the background to manage images/containers.
Task 4: Optimize with Multi-Stage Builds
I modified my Dockerfile to use multi-stage builds:
# Stage 1: Build
FROM node:18-alpine AS build
WORKDIR /app
COPY . .
RUN npm install
# Stage 2: Run minimal image
FROM gcr.io/distroless/nodejs18
WORKDIR /app
COPY --from=build /app .
CMD ["index.js"]
Comparison:
docker images
Before: ~150MB
After: ~35MB
π Multi-stage builds reduced size significantly, making the image faster and more secure.
Task 5: Manage Image with Docker Hub
Commands:
docker tag vaishnavi/sample-app:latest vaishnavi/sample-app:v1.0
docker login
docker push vaishnavi/sample-app:v1.0
docker pull vaishnavi/sample-app:v1.0
β Successfully pushed my image to Docker Hub.
Task 6: Persist Data with Docker Volumes
Commands:
docker volume create my_volume
docker run -d -v my_volume:/app/data vaishnavi/sample-app:v1.0
Why Volumes?
Docker volumes allow data persistence even when containers are deleted, ensuring logs, databases, and files are not lost.
Task 7: Configure Docker Networking
Commands:
docker network create my_network
docker run -d --name sample-app --network my_network vaishnavi/sample-app:v1.0
docker run -d --name my-db --network my_network -e MYSQL_ROOT_PASSWORD=root mysql:latest
β Containers communicated using the same custom network.
π Docker networking is critical for microservices, where different services (app, database, cache) need to interact.
Task 8: Orchestrate with Docker Compose
docker-compose.yml:
version: '3'
services:
app:
image: vaishnavi/sample-app:v1.0
ports:
- "8080:80"
networks:
- my_network
volumes:
- my_volume:/app/data
db:
image: mysql:latest
environment:
MYSQL_ROOT_PASSWORD: root
networks:
- my_network
networks:
my_network:
volumes:
my_volume:
Commands:
docker-compose up -d
docker-compose down
β Orchestrated multi-container setup with app + DB.
Task 9: Analyze with Docker Scout
Command:
docker scout cves vaishnavi/sample-app:v1.0 > scout_report.txt
Findings:
Critical CVEs: 0
High: 1 (dependency in
mysql
base image)Medium/Low: Few related to minor libraries
Recommendations:
Use updated base images
Regularly scan images before deployment
π Security scanning is essential to maintain secure deployments.
Task 10: Documentation & Reflection
All steps, commands, and learnings are documented in solution.md
.
Reflection
Docker has revolutionized modern development:
Benefits: Portability, scalability, faster builds, consistent environments.
Challenges: Learning curve, image security, managing orchestration at scale.
With multi-stage builds, Docker Hub, volumes, networks, and Compose, I now feel confident containerizing apps and managing multi-container setups.
π Key Learnings
Understood Virtualization vs Containerization and why containers are lightweight & scalable.
Built a sample app using a Dockerfile and ran it in a container.
Optimized images with multi-stage builds & distroless images (reduced size drastically β‘).
Managed images with Docker Hub (tag, push, pull).
Persisted data using Docker Volumes.
Connected services via Docker Networks.
Orchestrated multi-container apps using Docker Compose.
Analyzed image vulnerabilities with Docker Scout π.
π¬ This hands-on week showed me how Docker makes development consistent, portable, and production-ready.
π€ Connect With Me
π Blog Series: hashnode.com/@VaishnaviTandekar
π» GitHub Repo: 90DaysOfDevOps
π Hashtags:
#90DaysOfDevOps #Docker #DevOps #Containerization #Microservices #CloudNative
Subscribe to my newsletter
Read articles from Vaishnavi Tandekar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Vaishnavi Tandekar
Vaishnavi Tandekar
Hey there! Iβm Vaishnavi π Learning DevOps step by step π οΈ Writing what I learn so no one learns alone β¨