🎯 Whether you’re just exploring containers or preparing for real-world DevOps, this guide will set the stage.
Table of Contents
Open Table of Contents
🔧 Installation
Before we begin, install Docker on your system:
👉 Click here to visit the official Docker installation page
🐳 What is Docker? Why Use It?
Docker is an open-source platform that allows you to package, distribute, and run applications in isolated environments called containers.
It provides a standardized way to ensure software runs consistently across different environments. Everything runs in a lightweight, portable package — making development, testing, and deployment faster and more reliable.
🧱 Containers vs Virtual Machines
Feature | Containers | Virtual Machines |
---|---|---|
Isolation | Process-level | Full OS-level |
Speed | Lightweight and fast | Heavy and slow startup |
Size | Small (MBs) | Large (GBs) |
Use Cases | Microservices, CI/CD, App packaging | Full OS testing, legacy apps |
🧠 Docker Architecture
Docker is made up of the following components:
- Docker Engine: Core runtime environment.
- Docker CLI: Command-line interface to communicate with the engine.
- Docker Daemon (
dockerd
): Background service handling containers and images. - Docker Hub: A registry for sharing and downloading Docker images.
- Images & Containers: Blueprints vs instances.
🛠️ Key Docker Components
🔹 Images
- Immutable blueprint of an application.
- Versioned and portable.
- Pulled from registries like Docker Hub.
🔹 Containers
- Running instances of images.
- Isolated environments for applications.
- Can be started, stopped, restarted, or deleted.
🔹 Volumes
- Used for data persistence.
- Exist outside the container’s filesystem.
🔹 Networks
- Allow inter-container communication.
- Default types:
bridge
,host
, andnone
.
🧾 What is a Dockerfile?
A Dockerfile is a text-based script of instructions for building a Docker image.
Example:
FROM python:3.11
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "app.py"]
⚙️ Useful Docker Commands & Flags
🔍 Check Version & System Info
docker --version
docker info
📥 Pulling an Image
docker pull alpine
Downloads the Alpine base image.
🚀 Running a Container
Interactive shell inside Alpine:
docker run -it alpine sh
Running an nginx container on port 8080:
docker run -d -p 8080:80 --name web nginx
Common flags:
-d
: Detached mode-p
: Port mapping (host:container)--name
: Custom container name--rm
: Auto-remove on exit-v
: Mount a volume
📋 Managing Containers
List containers:
docker ps # Running only
docker ps -a # All, including stopped
Stop, start, remove containers:
docker stop mycontainer
docker start mycontainer
docker rm mycontainer
📦 Working with Images
List all images:
docker images
Remove an image:
docker rmi nginx
🧭 What’s Next?
In the next part, we’ll explore how to build your own Docker images using Dockerfiles, manage image layers efficiently, and follow best practices for optimized builds.
Stay tuned for Part 2: Building Docker Images Like a Pro.
🧠 Extra Learning: Read official Docker docs for deeper reference.