-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDocker-Interview-Question
More file actions
101 lines (51 loc) Β· 5.52 KB
/
Copy pathDocker-Interview-Question
File metadata and controls
101 lines (51 loc) Β· 5.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Docker-Interview-Question
What is Docker, and why is it used?
Answer: Docker is a containerization platform used for packaging, distributing, and running applications and their dependencies in isolated environments called containers. It provides consistency and portability across different environments.
What is a Docker container?
Answer: A Docker container is a lightweight, standalone executable package that includes everything needed to run a piece of software, including the code, runtime, system tools, and libraries.
What is the difference between a Docker container and a virtual machine (VM)?
Answer: Docker containers are much lighter and more efficient than VMs. Containers share the host OS kernel, making them faster to start, use fewer resources, and provide better performance.
How do you install Docker on different operating systems?
Answer: The installation process varies by OS. For example, you can use Docker Desktop on Windows and macOS, and on Linux, you can use distribution-specific package managers.
Explain the Docker image and Docker container relationship.
Answer: Docker images are read-only templates containing application code, libraries, and dependencies. Containers are instances of images that are runnable, writable, and can execute in isolation.
What is a Dockerfile, and how does it work?
Answer: A Dockerfile is a text file that defines the instructions to create a Docker image. It includes commands to copy files, install software, set environment variables, and more.
How do you build a Docker image from a Dockerfile?
Answer: You can use the docker build command, specifying the path to the Dockerfile and a name/tag for the resulting image.
What is Docker Compose, and why is it used?
Answer: Docker Compose is a tool for defining and running multi-container Docker applications. It allows you to define the services, networks, and volumes in a single file and start them with a single command.
What is a Docker registry?
Answer: A Docker registry is a repository for Docker images. Docker Hub is a popular public registry, and you can also set up private registries for your organization.
How do you push a Docker image to Docker Hub?
Answer: Use the docker push command, specifying the image name and tag, and authenticate with your Docker Hub account.
Explain Docker networking modes.
Answer: Docker provides different networking modes, including bridge, host, overlay, and macvlan, to control how containers communicate with each other and with the host system.
What is Docker Swarm, and how does it differ from Kubernetes?
Answer: Docker Swarm is Docker's native clustering and orchestration solution for managing a group of Docker hosts. Kubernetes is a more comprehensive container orchestration platform with a larger ecosystem.
How do you scale services in Docker Swarm?
Answer: You can use the docker service scale command to scale the number of replicas for a service in Docker Swarm.
What are Docker volumes, and why are they important?
Answer: Docker volumes are a way to persist data outside of a container. They are crucial for maintaining data between container restarts and for sharing data between containers.
Explain the concept of Docker storage drivers.
Answer: Docker storage drivers are responsible for managing the storage backend used by Docker containers. Common storage drivers include overlay2, aufs, and devicemapper.
How do you remove all stopped Docker containers?
Answer: You can use the docker container prune command to remove all stopped containers.
What is the purpose of a Docker-compose.yml file?
Answer: The docker-compose.yml file is used to define the services, networks, and volumes for a Docker Compose application, allowing you to manage multiple containers as a single unit.
How can you pass environment variables to a Docker container?
Answer: You can use the -e option with the docker run command to pass environment variables to a container.
What is Docker Hub, and how can you find Docker images there?
Answer: Docker Hub is a cloud-based registry for Docker images. You can search for Docker images on Docker Hub using the docker search command or by browsing the website.
Explain the concept of Docker layering.
Answer: Docker images are composed of multiple layers, where each layer represents a specific set of changes to the filesystem. Layering allows for efficient image sharing and reuse.
How do you troubleshoot a Docker container that fails to start?
Answer: You can check container logs using the docker logs command, inspect container configuration with docker inspect, and review the Dockerfile and entrypoint script for issues.
What is Docker Swarm mode, and how do you initialize a Swarm cluster?
Answer: Docker Swarm mode is a built-in orchestration feature for Docker. You can initialize a Swarm cluster using the docker swarm init command on the manager node.
How can you share data between Docker containers?
Answer: Docker volumes and Docker networks are commonly used to share data between containers. Volumes provide persistent storage, while networks allow containers to communicate.
What is Docker Health Check, and why is it used?
Answer: Docker Health Check is a feature that allows you to define a command or a script to periodically check the health of a container. It helps ensure the reliability of services.
What are Docker secrets, and how are they managed?
Answer: Docker secrets are a secure way to manage sensitive information, such as passwords or API keys, in a Docker Swarm. They are stored securely and made available to containers as files in the /run/secrets directory.