- Introduction to Docker
- Docker Architecture
- How to Install Docker?
- Advantages of Docker
- Docker Commands
- Docker network host
- Docker List Images
- Docker Repositories
- Docker Storage Drivers
- Docker Push
- Docker run Command
- Docker Container
- Docker Container Linking
- Docker Stop Container
- Docker List Containers
- Docker Registry
- Docker Volume
- Docker Images
- Docker Export
- Docker Import
- Introduction to Kubernates
- Kubernetes Architecture
- Kubernetes Tools
- Kubernetes Environment Variables
- Kubernetes Operators
- Kubernetes Secrets
- Kubernetes Control Plane
- Kubernetes Namespace
- Kubernetes Annotations
- Kubernetes Ingress
- Kubernetes Deployment
- Kubernetes Load Balancer
- Kubernetes Selector
- Introduction to Koobernate
- Kubernetes Replication Controller
- Kubernetes Daemonset
- kubernetes flannel
- Kubernetes service types
- Introduction to Kubernetes monitoring
- Kubernetes service types
- Kubernetes CNI
- Kubernetes DNS
- Kubernetes HPA
- Kubernetes YAML
- Kubernetes CRD
- Kubernetesinit Containers
- Kubernetes Port Forward
- Ehat Is Kubernetes Labels
- Kubernetes Endpoints
- Kubernetes Kustomize
- Kubernetes Kustomize
- Kubernetes orchestration
- Kubernetes Master Node
- Kubernetes Federation
- Kubernetes use local docker image
- Kubernetesyaml validator
- Kubernetes tolerations
- Kubernetes flux
- Kubernetes Prometheus
- Kubernetes Service
- Kubernetes Ingress Controller
- Kubernetesliveness probe
- Kubernetes security
- Kubernetes metrics server
Docker Interview Questions
Q1. What is Docker?
A Docker is defined as the platform for containerizing the applications to isolate them from each other in order to ensure high availability and more efficiency irrespective of the environments such as Development, Testing or Production. All the application related dependencies such as libraries, jar files, server related configurations, infrastructure-related elements will be packaged and formed as container called containerized application which does not need any dependency and works independently. It ensures the application to be run irrespective of external factors. Containers in Docker have support from Docker Engine and Host Operating System to support all the operational or infrastructural-related dependencies.
Q2. What are the components of Docker Architecture and explain?
This is the common Docker Interview Questions asked in an interview. The Docker works on client-server architecture. The Docker client establishes communication with the Docker Daemon. The Docker client and daemon can run on the same system. A Docket client can also be connected to a remote Docker daemon. The different types of Docker components in a Docker architecture are–
This performs Docker build pull and run operations to establish communication with the Docker Host. The Docker command uses Docker API to call the queries to be run.
This component contains Docker Daemon, Containers and its images. The images will be the kind of metadata for the applications which are containerized in the containers. The Docker Daemon establishes a connection with Registry.
This component will be storing the Docker images. The public registries are Docker Hub and Docker Cloud, which can be s used by anyone.
Q3. What is Docker Container?
A Docker Container is a form of encapsulation to the application which holds all the dependencies which share the kernel with other containers in the duration of running the isolated processes on the host operating system. A Docker container can be created by creating a Docker image. These Docker images can be run after that using Docker commands. Docker containers are the instances of the Docker images at the runtime. Docker images can be stored in any public host or private host like the Docker hub. Docker Image is a set of files that can be run in an isolated process.
Q4. What are Docker Image and Docker Hub?
The Docker Image is a set of files and a combination of parameters that will allow creating the instances to run in separate containers as an isolated process. The Docker hub is a kind of repository to the images where these images can be stored, and this access is public. The Docker run command can be used to create the instance called a container, which can be run using the Docker image. Docker hub is the largest public repository of the image containers, which is being maintained by the community of developers and individual contributors.
Q5. What are the different functionalities and applications of using Docker?
The different functionalities and applications of using and implementing Docker are as below:
- It simplifies the configuration and provides ease at infrastructure level configuration.
- It manages the code pipeline easily, which provides a consistent environment and stability in the application.
- It enables the isolation of the application.
- It improves the productivity of the developer by allowing the developer to solely concentrate on business logic.
- It enables a lot of debugging capabilities that provide extremely useful functionalities to implement.
- It enables rapid deployment in the form of virtualization at the operating system level.
- It reduces the utilization of multiple servers in the form of containerization.
Q6. What is a Docker Registry?
A Docker Registry is a place where all the Docker Images will be stored, and Docker Cloud and Docker Hub are the public registries where these images can be hosted upon. The Docker hub is the default storage for the Docker Images. An own registry can also be set up as per the requirement. Docker Data Center (DDC) can also be used, which includes DTR (Docker Trusted Registry). Docker store will provide the feature of buying and selling the Docker images.
Q7. What is the lifecycle of Docker Container?
This is the most popular Docker Interview Questions asked in an interview. The life cycle of the Docker container is as below:
- Create a container.
- Run the Docker container.
- Pause the Container.
- Unpause the Container.
- Start the Container.
- Stop the Container.
- Restart the Container.
- Kill the Container.
- Destroy the Container.
Q8. What are Docker Objects?
The Docker Objects are Docker Images, Services, and Docker Containers. A Docker Image is a read-only template with the configuration or runtime instructions for the Docker container. The Services allow scaling the containers across the different Docker Daemons. These all together work as Swarm.
Q9. What are Docker Namespaces?
The Namespaces in Docker is a technology that provides isolated workspaces called the Container. Namespaces provide a layer of isolation for the Docker containers.
Q10. What are the important Docker commands?
|dockerd||To launch Docker daemon.|
|build||To build an image file for docker.|
|create||To create a new container.|
|kill||To kill a container.|
|commit||To create a new image from container changes.|
11. What is Hypervisor?
A hypervisor is a software that makes virtualization possible. It is also called Virtual Machine Monitor. It divides the host system and allocates the resources to each divided virtual environment. You can basically have multiple OS on a single host system. There are two types of Hypervisors:
It’s also called Native Hypervisor or Bare metal Hypervisor. It runs directly on the underlying host system. It has direct access to your host’s system hardware and hence does not require a base server operating system.
This kind of hypervisor makes use of the underlying host operating system. It’s also called Hosted Hypervisor.
12. What is virtualization?
Virtualization is the process of creating a software-based, virtual version of something(compute storage, servers, application, etc.). These virtual versions or environments are created from a single physical hardware system. Virtualization lets you split one system into many different sections which act like separate, distinct individual systems. A software called Hypervisor makes this kind of splitting possible. The virtual environment created by the hypervisor is called Virtual Machine.
13. What is containerization?
Let me explain this is with an example. Usually, in the software development process, code developed on one machine might not work perfectly fine on any other machine because of the dependencies. This problem was solved by the containerization concept. So basically, an application that is being developed and deployed is bundled and wrapped together with all its configuration files and dependencies. This bundle is called a container. Now when you wish to run the application on another system, the container is deployed which will give a bug-free environment as all the dependencies and libraries are wrapped together. Most famous containerization environments are Docker and Kubernetes.
14. Difference between virtualization and containerization
Once you’ve explained containerization and virtualization, the next expected question would be differences. The question could either be differences between virtualization and containerization or differences between virtual machines and containers. Either way, this is how you respond.
Containers provide an isolated environment for running the application. The entire user space is explicitly dedicated to the application. Any changes made inside the container is never reflected on the host or even other containers running on the same host. Containers are an abstraction of the application layer. Each container is a different application.
Whereas in Virtualization, hypervisors provide an entire virtual machine to the guest(including Kernal). Virtual machines are an abstraction of the hardware layer. Each VM is a physical machine.
15. What is a Dockerfile?
Let’s start by giving a small explanation of Dockerfile and proceed by giving examples and commands to support your arguments.
Docker can build images automatically by reading the instructions from a file called Dockerfile. A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build, users can create an automated build that executes several command-line instructions in succession.
16. What is Docker Machine?
Docker machine is a tool that lets you install Docker Engine on virtual hosts. These hosts can now be managed using the docker-machine commands. Docker machine also lets you provision Docker Swarm Clusters.
Docker Basic Commands
Once you’ve aced the basic conceptual questions, the interviewer will increase the difficulty level. So let’s move on to the next section of this Docker Interview Questions article. This section talks about the commands that are very common amongst docker users.
17. How to check for Docker Client and Docker Server version?
The following command gives you information about Docker Client and Server versions:
$ docker version
18. How do you get the number of containers running, paused and stopped?
You can use the following command to get detailed information about the docker installed on your system.
$ docker info
You can get the number of containers running, paused, stopped, the number of images and a lot more.
19. How to login into docker repository?
You can use the following command to login into hub.docker.com:
$ docker login
You’ll be prompted for your username and password, insert those and congratulations, you’re logged in.
20. If you wish to use a base image and make modifications or personalize it, how do you do that?
You pull an image from docker hub onto your local system
It’s one simple command to pull an image from docker hub:
$ docker pull < image_name>
21. How do you create a docker container from an image?
Pull an image from docker repository with the above command and run it to create a container. Use the following command:
$ docker run -it -d < image_name>
Most probably the next question would be, what does the ‘-d’ flag mean in the command?
-d means the container needs to start in the detached mode. Explain a little about the detach mode. Have a look at this blog to get a better understanding of different docker commands.
22. How do you list all the running containers?
The following command lists down all the running containers:
23. Suppose you have 3 containers running and out of these, you wish to access one of them. How do you access a running container?
The following command lets us access a running container:
$ docker exec -it < container id> bash
The exec command lets you get inside a container and work with it.
24. How to start, stop and kill a container?
The following command is used to start a docker container:
$ docker start < container_id>
and the following for stopping a running container:
$ docker stop < container_id>
kill a container with the following command:
$ docker kill < container_id>
25. Can you use a container, edit it, and update it? Also, how do you make it a new and store it on the local system?
Of course, you can use a container, edit it and update it. This sounds complicated but its actually just one command.
$ docker commit < conatainer id>< username/imagename>
26. Once you’ve worked with an image, how do you push it to docker hub?
$ docker push < username/image name>
27. How to delete a stopped container?
Use the following command to delete a stopped container:
$ dockerrm< container id>
28. Where all do you think Docker is being used?
When asked such a question, respond by talking about applications of Docker. Docker is being used in the following areas:
Docker lets you put your environment and configuration into code and deploy it.
Code Pipeline Management:
There are different systems used for development and production. As the code travels from development to testing to production, it goes through a difference in the environment. Docker helps in maintaining the code pipeline consistency.
Using Docker for development gives us two things – We’re closer to production and development environment is built faster.
As containers are applications wrapped together with all dependencies, your apps are isolated. They can work by themselves on any hardware that supports Docker.
Docker supports various debugging tools that are not specific to containers but work well with containers.
Docker lets you have multi-tenant applications avoiding redundancy in your codes and deployments.
Docker eliminates the need to boost an entire OS from scratch, reducing the deployment time.
29. How is Docker different from other containerization methods?
Docker containers are very easy to deploy in any cloud platform. It can get more applications running on the same hardware when compared to other technologies, it makes it easy for developers to quickly create, ready-to-run containerized applications and it makes managing and deploying applications much easier. You can even share containers with your applications.
If you have some more points to add you can do that but make sure the above explanation is there in your answer.
30. What platforms does docker run on?
This is a very straightforward question but can get tricky. Do some company research before going for the interview and find out how the company is using Docker. Make sure you mention the platform company is using in this answer.
Docker runs on various Linux administration:
- Ubuntu 12.04, 13.04 et al
- Fedora 19/20+
- RHEL 6.5+
- CentOS 6+
- openSUSE 12.3+
- CRUX 3.0+
It can also be used in production with Cloud platforms with the following services:
- Amazon EC2
- Amazon ECS
- Google Compute Engine
- Microsoft Azure