Basic Docker Questions
1. What is Docker?
Answer:
Docker is a containerization platform that packages an application and its dependencies into a lightweight container so it can run consistently across different environments.
2. What is a Docker container?
Answer:
A Docker container is a running instance of a Docker image. It includes the application, libraries, and runtime, isolated from the host system.
3. What is a Docker image?
Answer:
A Docker image is a read-only template used to create containers. It contains application code, dependencies, and configuration.
4. Difference between Docker image and container?
Answer:
Image: Blueprint (static, read-only)
Container: Running instance of an image (dynamic)
5. Why do we use Docker?
Answer:
Environment consistency
Easy deployment
Lightweight compared to VMs
Faster startup
Supports microservices and CI/CD
6. Is Docker a virtual machine?
Answer:
No. Docker containers share the host OS kernel, while virtual machines run their own OS. Docker is faster and more lightweight.
🔹 Docker Architecture Questions
7. What are the main components of Docker?
Answer:
Docker Client
Docker Daemon
Docker Images
Docker Containers
Docker Registry (Docker Hub)
8. What is Docker Daemon?
Answer:
Docker Daemon (dockerd) runs in the background and handles building, running, and managing containers.
9. What is Docker Hub?
Answer:
Docker Hub is a public registry where Docker images are stored and shared.
10. What is /var/run/docker.sock?
Answer:
It is a Unix socket used by Docker client to communicate with the Docker daemon.
🔹 Dockerfile & Build Questions
11. What is a Dockerfile?
Answer:
A Dockerfile is a text file that contains instructions to build a Docker image.
12. What are common Dockerfile instructions?
Answer:
FROM
RUN
COPY
WORKDIR
EXPOSE
CMD
ENTRYPOINT
13. Difference between CMD and ENTRYPOINT?
Answer:
ENTRYPOINT → fixed command
CMD → default arguments (can be overridden)
14. What is a multi-stage build?
Answer:
A multi-stage build uses multiple FROM statements to reduce image size by copying only required artifacts into the final image.
15. Why use .dockerignore?
Answer:
To exclude unnecessary files from the Docker build context, reducing image size and build time.
🔹 Container Management Questions
16. How do you list running containers?
Answer:
docker ps
17. How do you list all containers?
Answer:
docker ps -a
18. How do you stop and remove a container?
Answer:
docker stop
docker rm
19. How do you enter a running container?
Answer:
docker exec -it /bin/bash
20. How do you view container logs?
Answer:
docker logs
🔹 Docker Volumes & Storage
21. What is a Docker volume?
Answer:
A Docker volume is used to persist data outside the container lifecycle.
22. Difference between volume and bind mount?
Answer:
Volume: Managed by Docker (recommended)
Bind mount: Uses host directory directly
23. Why are volumes important?
Answer:
Because containers are temporary, volumes ensure data is not lost when containers stop or restart.
🔹 Networking Questions
24. What is the default Docker network?
Answer:
Bridge network.
25. How do containers communicate?
Answer:
Containers in the same Docker network communicate using container names as hostnames.
26. Difference between bridge and host network?
Answer:
Bridge: Isolated network (default)
Host: Shares host’s network directly
🔹 Docker Compose
27. What is Docker Compose?
Answer:
Docker Compose is a tool used to define and run multi-container applications using a docker-compose.yml file.
28. When should you use Docker Compose?
Answer:
When your application has multiple services like web server, database, cache, etc.
🔹 Debugging & Errors
29. What does “permission denied /var/run/docker.sock” mean?
Answer:
The user does not have permission to access Docker daemon.
Fix by adding user to the docker group.
- What causes io: read/write on closed pipe error?
Answer:
It usually occurs due to Docker daemon permission issues, not Dockerfile errors.
🔹 Advanced / Conceptual Questions
31. How is Docker different from Kubernetes?
Answer:
Docker → containerization
Kubernetes → orchestration (scaling, self-healing, load balancing)
32. How do you reduce Docker image size?
Answer:
Use slim/alpine images
Multi-stage builds
Remove unnecessary files
Use .dockerignore
33. Can Docker containers run without Docker?
Answer:
No. Containers need a container runtime like Docker or containerd.
34. What is BuildKit?
Answer:
BuildKit is Docker’s modern build engine that improves performance, caching, and parallel builds.
35. Explain Docker in one line (HR question)
Answer:
Docker allows developers to build, ship, and run applications consistently using containers.
Top comments (0)