Here is a list of some very basic Docker interview questions. Answers are written on the basis of Docker Guide.
1- What is Docker?
Ans: Docker is an open-source containerization platform to develop, package, shipping, and running applications. It enables the separation of applications from infrastructure. Using docker we can package applications with all underlying dependencies, makes packaged application portable, and run apps in isolated space. Using docker we can reduce development, build, and deployment timings using CI/CD. Unlike virtualization, we can run several containers separately on the same Host.
2- What is Docker Platform?
Ans: Docker provides the ability to package and run applications in a loosely isolated environment known as a container. For this Docker provides tools and a Platform to manage the life cycle of Docker containers like building docker images, distribution, running, etc.
3- What is Docker Engine?
Ans: Docker Engine is a Client service application, which is 3 major components. The server is also known as Docker Demon, a REST API interface to be accessed by programs to control the server and a CLI to do operation on the docker platform.
The CLI uses the Docker REST API to control or interact with the Docker daemon through scripting or direct CLI commands. Many other Docker applications use the underlying API and CLI.
4- When you will use Docker?
Ans: We can use Docker in an agile environment where the developer needs to develop, build, test, share, and push code to production in form of containers. Containers are a very good choice for CI/CD.
Uses are containers also provide portability and very easy to scale abilities.
5- Tell me about Docker architecture?
Ans: Docker has 3 major components, Client, Host, and Registry.
6- What is Docker Demon?
Ans: Docker demon is Server and Host running as service. The Docker daemon (
dockerd) listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. A daemon can also communicate with other daemons (On different hosts) to manage Docker services.
7- What is the Docker registry?
Ans: A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is configured to look for images on Docker Hub by default. You can even run your own private registry and another third party registry like AWS ECR.
When you use the
docker pull or
docker run commands, the required images are pulled from your configured registry. When you use the command, your image is pushed to your configured registry.
8- What is the meaning of Docker objects?
Ans: When you use Docker, you are creating and using images, containers, networks, volumes, plugins, and other objects.
9- What are Docker Images?
Ans: An image is a read-only template with instructions for creating a Docker container. Often, an image is based on another image, with some additional customization. For example, you may build an image that is based on the
ubuntu image, but installs the Apache web server and your application, as well as the configuration details needed to make your application run.
10- How to create a Docker image?
Ans: To build your own image, you create a Dockerfile with a simple syntax for defining the steps needed to create the image and run it. Each instruction in a Dockerfile creates a layer in the image. When you change the Dockerfile and rebuild the image, only those layers which have changed are rebuilt. This is part of what makes images so lightweight, small, and fast when compared to other virtualization technologies.
11- What is a Docker file?
Ans: Dockerfile is a simple text file with a simple syntax for defining the steps needed to create the image and run it.
12- Write is basic Docker compose file?
Ans: Using below syntax one can write docker file
FROM ubuntu:18.04 COPY . /app RUN make /app CMD python /app/app.py
Each instruction creates one layer:
FROMcreates a layer from the
COPYadds files from your Docker client’s current directory.
RUNbuilds your application with
CMDspecifies what command to run within the container.
13- What are docker services and their uses?
Ans: Services allow you to scale containers across multiple Docker daemons, which all work together as a swarm with multiple managers and workers. Each member of a swarm is a Docker daemon, and all the daemons communicate using the Docker API. A service allows you to define the desired state, such as the number of replicas of the service that must be available at any given time. By default, the service is load-balanced across all worker nodes.
14- What is the control groups (cgroups)?
Ans: Docker Engine on Linux also relies on another technology called control groups (
cgroups). A cgroup limits an application to a specific set of resources. Control groups allow Docker Engine to share available hardware resources to containers and optionally enforce limits and constraints. For example, you can limit the memory available to a specific container.
15- What is union file system?
Ans: Union file systems, or UnionFS, are file systems that operate by creating layers, making them very lightweight and fast. Docker Engine uses UnionFS to provide the building blocks for containers. Docker Engine can use multiple UnionFS variants, including AUFS, btrfs, vfs, and DeviceMapper.
16- What is the container format?
Ans: Docker Engine combines the namespaces, control groups, and UnionFS into a wrapper called a container format.
17- What are Docker’s life cycle?
Ans: There is no straight answer for this, refre some links