🔰 Basics of Containers (1–10)
1. What is a container?
Answer:
A container is a lightweight, isolated environment that packages an application with its dependencies and runs consistently across systems.
2. What is Docker?
Answer:
Docker is a containerization platform used to build, ship, and run containers efficiently.
![]() |
| Docker container architecture diagram, image to container flow |
3. Difference between VM and Container?
Answer:
| Virtual Machine | Container |
|---|---|
| Heavy | Lightweight |
| Own OS | Shares host OS |
| Slow startup | Fast startup |
4. Why are containers faster than VMs?
Answer:
Containers reuse the host OS kernel, avoiding full OS boot.
5. What problems does Docker solve?
Answer:
-
Environment mismatch
-
Dependency conflicts
-
Deployment inconsistency
6. What is Docker Image?
Answer:
A read-only blueprint used to create Docker containers.
7. What is Docker Container?
Answer:
A running instance of a Docker image.
8. What is Docker Engine?
Answer:
The core service that builds and runs containers.
9. What is Docker Hub?
Answer:
A public container registry for Docker images.
10. What is container immutability?
Answer:
Containers are not modified after creation—new versions require new images.
⚙️ Docker Core Concepts (11–25)
11. What is Dockerfile?
Answer:
A text file containing instructions to build a Docker image.
12. Common Dockerfile instructions?
Answer:
13. What is FROM used for?
Answer:
Defines the base image.
14. What is CMD vs ENTRYPOINT?
Answer:
-
CMD: default command -
ENTRYPOINT: fixed executable
15. What is Docker layer?
Answer:
Each instruction creates a cached layer to speed up builds.
16. What is .dockerignore?
Answer:
Prevents unnecessary files from being copied into image.
17. What is Docker volume?
Answer:
Persistent storage outside container lifecycle.
18. Difference between volume and bind mount?
Answer:
Volumes are managed by Docker; bind mounts map host paths.
19. What is Docker network?
Answer:
Allows containers to communicate with each other.
20. Types of Docker networks?
Answer:
-
Host
-
None
-
Overlay
21. What is container port mapping?
Answer:
Maps container ports to host ports.
22. What is Docker registry?
Answer:
A storage system for Docker images.
23. What is image tagging?
Answer:
Assigning version names to images (app:v1).
24. What is Docker cache?
Answer:
Reuse of image layers to speed up builds.
25. What is multi-stage build?
Answer:
Reduces image size by separating build and runtime stages.
🧠 Advanced Docker (26–40)
26. What is Docker Compose?
Answer:
Tool to define and run multi-container applications.
27. What is docker-compose.yml?
Answer:
YAML file defining services, networks, volumes.
28. What is container orchestration?
Answer:
Automated container management (scaling, healing, deployment).
29. Why Kubernetes over Docker alone?
Answer:
Docker runs containers; Kubernetes manages containers at scale.
30. What is stateless vs stateful container?
Answer:
-
Stateless: no stored data
-
Stateful: uses volumes/databases
31. What is container health check?
Answer:
Ensures container is running correctly.
32. What is Docker security best practice?
Answer:
-
Minimal base images
33. What is Docker secret?
Answer:
Secure way to store passwords & API keys.
34. What is image vulnerability scanning?
Answer:
Detecting security issues in images.
35. What is Docker build context?
Answer:
Files sent to Docker daemon during build.
36. What is container logging?
Answer:
Standard output captured by Docker logging drivers.
37. What is Docker swarm?
Answer:
Docker’s native clustering & orchestration tool.
38. What causes large Docker images?
Answer:
-
Unused dependencies
-
No multi-stage build
-
Large base images
39. How to reduce image size?
Answer:
-
Alpine images
-
Multi-stage builds
-
Clean cache
40. What is OCI?
Answer:
Open Container Initiative – defines container standards.
🧪 Real-World & DevOps Scenarios (41–50)
41. How Docker helps CI/CD?
Answer:
Provides consistent build & deployment environments.
42. How do you version Docker images?
Answer:
Semantic versioning (v1.0.0).
![]() |
| DevOps engineer using Docker, containers running on cloud servers |
43. How do you rollback a Docker deployment?
Answer:
Deploy previous image tag.
44. How do containers communicate?
Answer:
Via Docker networks using service names.
45. How do you debug a container?
Answer:
Using docker exec -it.
46. How do you monitor containers?
Answer:
Prometheus, Grafana, Docker stats.
47. How do you handle secrets in production?
Answer:
Env vars, Vault, Kubernetes Secrets.
48. What happens if container crashes?
Answer:
Restart policies or orchestrator handles it.
49. Docker vs Podman?
Answer:
Podman is daemon-less & rootless.
50. Why Docker is critical for modern apps?
Answer:
Because of scalability, portability, and speed.
🧩 100% WORKING DOCKER SCRIPTS
✅ Script 1: Simple Node.js App
app.js
Dockerfile
Run
✅ Script 2: Nginx Container
✅ Script 3: Docker Compose (Node + Redis)
docker-compose.yml
Run

