Unit 1: Docker Fundamentals & Installation

Part A: Docker Fundamentals

1. What is Docker?

Docker is a platform for developing, shipping and running applications in lightweight isolated environments called containers.

Hinglish: Docker code + dependencies + runtime/configuration ko package karke consistent environment mein run karne deta hai. Isse "mere system par chal raha hai" problem reduce hoti hai.

2. Docker vs Virtual Machine

Hinglish: VM generally heavier hoti hai; containers lightweight aur fast start hote hain.
Host OS Docker Engine Containers App + Dependencies

3. Docker Architecture & Objects

4. Container & Image Lifecycle

Container: Image exists → container created → started → running → stopped/restarted → removed.

Stop karne se container automatically delete nahi hota. Use docker rm.

Image: Dockerfile → build → image → run → container → tag → push → registry.

Part B: Installation & Opening Docker

Windows/macOS

Download Docker Desktop, run installer. For Windows, keep the recommended WSL 2 option. Restart if requested.

Verify Installation

Open Terminal/PowerShell and run:

docker version
docker info
Hinglish: Agar docker version Client aur Server dono dikhaye, iska matlab CLI Docker engine se communicate kar paa raha hai.

Part C: First 30 Minutes with Docker

1. First Container — hello-world

Docker downloads the image if needed, creates a container, runs it, prints a message, and exits.

docker run hello-world

2. First Real Server — Nginx

Run Nginx detached (-d) and publish port 80 inside the container to host port 8080.

docker pull nginx
docker run -d --name mynginx -p 8080:80 nginx

Open browser: http://localhost:8080

3. Stop / Start / Remove

Hinglish: Stop karne ka matlab delete karna nahi hai. Stop sirf process ko rokti hai. Remove karne ke liye 'rm' use hota hai.
docker stop mynginx
docker start mynginx
docker rm mynginx  # Only works if stopped
docker rmi nginx   # Removes the image

Part P: First Day Practical Lab (Do This Exactly)

Follow these exact steps in your terminal to get comfortable with basic Docker commands.
# 1. Verify
docker version

# 2. Test
docker run hello-world

# 3. List
docker ps
docker ps -a

# 4. Pull & Run Nginx
docker pull nginx
docker run -d --name mynginx -p 8080:80 nginx

# 5. Check Logs
docker logs mynginx
docker logs -f mynginx

# 6. Stop & Remove
docker stop mynginx
docker rm mynginx