Docker Deep Dives
- What is Docker?
Docker is an open-source containerization platform that allows developers to package an application along with its dependencies, libraries, and runtime into a container.
Unlike virtual machines, Docker containers share the host operating system kernel, making them lightweight, portable, and fast.
Why Docker?
Build once, run anywhere Faster deployments Consistent environments Lightweight containers Easy scaling Simplified CI/CD pipelines
Docker Workflow
Developer │ ▼ Write Application │ ▼ Dockerfile │ ▼ Docker Image │ ▼ Docker Container │ ▼ Deploy Anywhere
2. Docker Architecture Components
+----------------------+ | Docker Client | | docker build/run | +----------+-----------+ | | REST API | ▼ +----------------------+ | Docker Daemon | | dockerd | +----+-----------+-----+ | | Creates | | Manages ▼ ▼ Docker Images Docker Containers | ▼ Docker Volumes | ▼ Docker Networks
|
▼
Docker Registry
(Docker Hub/Private)
Docker Architecture Explanation Docker Client
Used by users to execute commands.
Examples
docker build docker run docker pull docker push Docker Daemon (dockerd)
Responsible for
Building images Running containers Managing networks Managing volumes Communicating with Docker Hub Docker Images
Read-only templates used to create containers.
Example
nginx ubuntu python node mysql Docker Containers
Running instance of an image.
Example
docker run nginx Docker Registry
Stores Docker Images.
Examples
Docker Hub AWS ECR Azure ACR Google GCR 3. Docker Images vs Containers Docker Image Docker Container Blueprint Running Instance Read-only Read-write Immutable Mutable Created using Dockerfile Created from Image Cannot execute Executes Application
Example
Dockerfile │ ▼ Docker Image │ docker run ▼ Docker Container 4. Dockerfile
A Dockerfile is a text file containing instructions to build a Docker image.
Example
FROM nginx:latest
index.html /usr/share/nginx/html/
EXPOSE 80
CMD ["nginx","-g","daemon off;"] Common Dockerfile Instructions FROM
Base Image
FROM ubuntu:22.04 WORKDIR
Sets working directory.
WORKDIR /app COPY
Copies files.
COPY . . ADD
Copies + downloads archives.
ADD app.tar.gz /app RUN
Executes commands while building image.
RUN apt update CMD
Runs when container starts.
CMD ["node","app.js"] ENTRYPOINT
Default executable.
ENTRYPOINT ["python"] EXPOSE
Expose container port.
EXPOSE 8080 ENV
Environment variables.
ENV APP_ENV=production Dockerfile Build Process Dockerfile │ docker build │ ▼ Docker Image │ docker run ▼ Container 5. Docker Volumes
Volumes provide persistent storage.
Without Volume
Container │ Delete │ Data Lost
With Volume
Volume │ Container │ Delete Container │ Volume Exists
Example
docker volume create myvolume
Run
docker run -v myvolume:/app/data nginx
Benefits
Persistent Storage Backup Share Data Better Performance 6. Docker Networks
Docker Networks enable communication between containers.
Types
Bridge
Default network.
Container A │ Bridge Network │ Container B Host
Uses Host Networking.
None
No Networking.
Overlay
Multiple Docker Hosts.
Macvlan
Assigns Physical MAC Address.
Create Network
docker network create my-network
Run
docker run --network=my-network nginx 7. Docker Compose
Docker Compose manages multi-container applications.
Example
Frontend │ Backend │ Database
All managed using one file.
Example
version: "3"
services:
web: image: nginx
redis: image: redis
mysql: image: mysql
Commands
docker compose up -d
docker compose ps
docker compose logs
docker compose down Docker Compose Architecture docker-compose.yml │ ▼ Docker Compose │ ┌──────┴───────────┐ │ │ ▼ ▼ Nginx Redis │ │ └──────────┬───────┘ ▼ Docker Network 8. Docker Hub
Docker Hub is Docker's public registry.
Purpose
Store Images Share Images Pull Images Version Control
Workflow
Dockerfile │ docker build │ Image │ docker tag │ docker push ▼ Docker Hub │ docker pull ▼ Anywhere
Commands
docker login
docker build
docker tag
docker push
docker pull
About the author
- Hi there! I'm a passionate AWS DevOps Engineer with 2+ years of experience in building and managing scalable, reliable, and secure cloud infrastructure. I'm excited to share my knowledge and insights through this blog. Here, you'll find articles on: AWS Services: Deep dives into core AWS services like EC2, S3, Lambda, and more. DevOps Practices: Best practices for CI/CD, infrastructure as code, and automation. Security: Tips and tricks for securing your AWS environments. Serverless Computing: Building and deploying serverless applications. Troubleshooting: Common issues and solutions in AWS. I'm always eager to learn and grow, and I hope this blog can be a valuable resource for fellow DevOps enthusiasts. Feel free to connect with me on [LinkedIn/Twitter] or leave a comment below!
Comments
Join the discussionNo comments yet. Be the first to comment.
