1️⃣ What is Docker?
A: Docker is an open-source platform for containerization that packages apps with dependencies into lightweight, portable units—ensures "build once, run anywhere" across dev, test, and prod environments.
2️⃣ What is a Container?
A: A lightweight, standalone executable that bundles code, runtime, libraries, and config—isolated via namespaces and cgroups, starts in seconds unlike VMs, perfect for microservices.
3️⃣ Docker vs Virtual Machines (VMs)
⦁ Docker: Shares host kernel for low overhead (MBs of RAM), fast startup (<1s), ideal for dense packing.
⦁ VMs: Emulates full hardware/OS (GBs of RAM), slower boot (minutes), better for legacy apps needing isolation.
4️⃣ What is a Docker Image?
A: A read-only, layered template (like a snapshot) for creating containers—built via Dockerfile, cached layers speed rebuilds; pull from registries like Docker Hub for bases like Ubuntu.
5️⃣ Common Docker Commands:
⦁
docker run → Start container from image (e.g., docker run -d nginx).⦁
docker build → Create image from Dockerfile (e.g., docker build -t myapp.).⦁
docker ps → List running containers (-a for all).⦁
docker images → List local images.⦁
docker stop → Halt a container (rm to remove).⦁
docker pull → Fetch from registry.⦁
docker push → Upload to registry.6️⃣ What is a Dockerfile?
A: A script with instructions (FROM, RUN, COPY, CMD) to automate image builds—e.g.,
FROM node:14 starts with Node, RUN npm install adds deps; multi-stage reduces final size.7️⃣ What is Docker Compose?
A: YAML-based tool for orchestrating multi-container apps—defines services, networks, volumes in
docker-compose.yml; run with up for local dev stacks like app + DB.8️⃣ What is Docker Hub?
A: Cloud registry for public/private images, like GitHub for containers—search/pull official ones (e.g.,
postgres), or push your own for team sharing.9️⃣ What is Docker Swarm?
A: Native clustering for managing Docker nodes as a "swarm"—handles service scaling, load balancing, rolling updates; great for simple orchestration before Kubernetes.
🔟 What are Docker Volumes?
A: Persistent data storage outside containers—survives restarts; bind mounts link host dirs, named volumes manage via
docker volume create for app data like DBs.1️⃣1️⃣ What is Docker Networking?
A: Enables container communication—bridge (default, isolated), host (shares host network), overlay (Swarm multi-host), none (isolated); use
docker network create for custom.1️⃣2️⃣ How to Build a Docker Image?
A: Create Dockerfile, then
docker build -t myimage:v1. in the dir—tags for versioning; optimize with.dockerignore to skip files like node_modules.1️⃣3️⃣ Difference between CMD and ENTRYPOINT?
⦁ CMD: Provides default args (overridable, e.g., via
docker run), like CMD ["nginx", "-g", "daemon off;"].⦁ ENTRYPOINT: Sets fixed executable (args append), e.g.,
ENTRYPOINT ["python"] + CMD ["app.py"] runs as python app.py.1️⃣4️⃣ What is Container Orchestration?
A: Automates deployment/scaling of container clusters—Kubernetes leads (with pods/services), Swarm for Docker-native; handles failover, autoscaling in prod.
1️⃣5️⃣ How to Handle Docker Security?
A: Use non-root users (
USER), scan with Trivy/Clair, minimal bases (alpine), secrets mgmt (Docker Secrets), limit resources (--cpus 1), and sign images with cosign.💬 Tap ❤️ if you found this useful!