Q1. What is Docker?
Docker is an open-source lightweight containerization technology.
It has gained widespread popularity in the cloud and application packaging world.
It allows you to automate the deployment of applications in lightweight and portable containers.
In other words, Docker is a containerization platform that packages your application and all its dependencies together in the form of containers so as to ensure that your application works seamlessly in any environment, be it development, test, or production. Docker containers, wrap a piece of software in a complete filesystem that contains everything needed to run: code, runtime, system tools, system libraries, etc. It wraps basically anything that can be installed on a server. This guarantees that the software will always run the same, regardless of its environment.
Q2. What is Hypervisor?
A hypervisor is a software that makes virtualization happen which is sometimes referred to as the Virtual Machine Monitor. This divides the resources of the host system and allocates them to each guest environment installed.
This means that multiple OS can be installed on a single host system. Hypervisors are of 2 types:
1. Native Hypervisor: This type is also called a Bare-metal Hypervisor and runs directly on the underlying host system which also ensures direct access to the host hardware which is why it does not require base OS.
2. Hosted Hypervisor: This type makes use of the underlying host operating system which has the existing OS installed.
Q3. 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.
Q4. What is containerization?
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. The most famous containerization environments are Docker and Kubernetes.
Q5. What is the difference between virtualization and containerization?
The question indirectly explains the difference between virtual machines and Docker containers.
Virtualization:
1. This helps developers to run and host multiple OS on the hardware of a single physical server.
2. Hypervisors provide overall virtual machines to the guest operating systems.
3. These virtual machines form an abstraction of the system hardware layer this means that each virtual machine on the host acts like a physical machine.
Containerization:
1. This helps developers to deploy multiple applications using the same operating system on a single virtual machine or server.
2. Containers ensure isolated environment/ user spaces are provided for running the applications. Any changes done within the container do not reflect on the host or other containers of the same host.
3. Containers form an abstraction of the application layer which means that each container constitutes a different application.
Q6. What are the advantages of using a Docker container?
Below is the advantage of using Docker.
1. Offers an efficient and easy initial setup.
2. Allows you to describe your application lifecycle in detail.
3. Simple configuration and interaction with Docker Compose.
4. Documentation provides every bit of information.
Q7. What are the states of the Docker container?
Important states of Docker container are:
Running
Paused
Restarting
Exited
Q8. What are the important features of Docker?
Here are the essential features of Docker:
Easy Modeling
Version control
Placement/Affinity
Application Agility
Developer Productivity
Operational Efficiencies
Q9. What is the common instruction in Dockerfile?
FROM: This is used to set the base image for upcoming instructions. A docker file is considered to be valid if it starts with the FROM instruction.
LABEL: This is used for image organization based on projects, modules, or licensing. It also helps in automation as we specify a key-value pair while defining a label that can be later accessed and handled programmatically.
RUN: This command is used to execute instructions following it on the top of the current image in a new layer. Note that with each RUN command execution, we add layers on top of the image and then use that in subsequent steps.
CMD: This command is used to provide default values of an executing container. In cases of multiple CMD commands the last instruction would be considered.
Q10. 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.
Q11. Write a Docker file to create an image?
FROM openjdk:8
ADD target/api-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/api.jar"]
Q12. Where the docker volumes are stored?
You need to navigate:
/var/lib/docker/volumes
Q13. What is a Docker image?
The Docker image help to create Docker containers. You can create the Docker image with the build command.
Due to this, it creates a container that starts when it begins to run. Every docker image is stored in the Docker registry.
In another way, They are executable packages(bundled with application code & dependencies, software packages, etc.) for the purpose of creating containers. Docker images can be deployed to any docker environment and the containers can be spun up there to run the application.
Q14. What is Docker Engine?
Docker daemon or Docker engine represents the server. The docker daemon and the clients should be run on the same or remote host, which can communicate through command-line client binary and full RESTful API.
Q15. Explain Registries.
A Docker image registry, in simple terms, is an area where the docker images are stored. Instead of converting the applications to containers each and every time, a developer can directly use the images stored in the registry. This image registry can either be public or private and Docker hub is the most popular and famous public registry available.
Q16. How many Docker components are there?
There are three docker components, they are - Docker Client, Docker Host, and Docker Registry.
Docker Client: This component performs “build” and “run” operations for the purpose of opening communication with the docker host.
Docker Host: This component has the main docker daemon and hosts containers and their associated images. The daemon establishes a connection with the docker registry.
Docker Registry: This component stores the docker images. There can be a public registry or a private one. The most famous public registries are Docker Hub and Docker Cloud.
Q17. What is a Docker Hub?
It is a public cloud-based registry provided by Docker for storing public images of the containers along with the provision of finding and sharing them.
The images can be pushed to Docker Hub through the docker push command.
Q18. Explain Docker Architecture?
Docker Architecture consists of a Docker Engine which is a client-server application with three major components:
A server is a type of long-running program called a daemon process (the docker command).
A REST API specifies interfaces that programs can use to talk to the daemon and instruct it on what to do.
A command line interface (CLI) client (the docker command).
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.
Q19. What is the memory-swap flag?
Memory-swap is a modified flag that only has meaning if- memory is also set. Swap allows the container to write express memory requirements to disk when the container has exhausted all the RAM which is available to it.
Q20. Tell us something about Docker Compose.
Docker Compose is a YAML file that contains details about the services, networks, and volumes for setting up the Docker application. So, you can use Docker Compose to create separate containers, host them and get them to communicate with each other. Each container will expose a port for communicating with other containers.
Q21. Explain Docker Swarm?
Docker Swarm is a native gathering for docker which helps you to a group of Docker hosts into a single and virtual docker host. It offers the standard docker application program interface.
Q22. What is a Docker Namespace?
A namespace is one of the Linux features and an important concept of containers. Namespace adds a layer of isolation in containers. Docker provides various namespaces in order to stay portable and not affect the underlying host system. Few namespace types supported by Docker – PID, Mount, IPC, User, Network.
Q23. What is the lifecycle of a Docker Container?
Docker containers have the following lifecycle:
Create a container
Run the container
Pause the container(optional)
Un-pause the container(optional)
Start the container
Stop the container
Restart the container
Kill the container
Destroy the container
Q24. 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.
Q25. What is the best way of deleting a container?
We need to follow the following two steps for deleting a container:
- docker stop <container_id>
- docker rm <container_id>
Q26. Can you tell the difference between CMD and ENTRYPOINT?
CMD command provides executable defaults for an executing container. In case the executable has to be omitted then the usage of ENTRYPOINT instruction along with the JSON array format has to be incorporated.
ENTRYPOINT specifies that the instruction within it will always be run when the container starts.
This command provides an option to configure the parameters and the executables. If the DockerFile does not have this command, then it would still get inherited from the base image mentioned in the FROM instruction. The most commonly used ENTRYPOINT is /bin/sh or /bin/bash for most of the base images. As part of good practices, every DockerFile should have at least one of these two commands.
Exception Handling Interview Questions
DBMS Interview Questions Set -1
DBMS Interview Questions Set -2
JPA Interview Questions Set -1
Spring Boot Interview Questions Set 1
Spring Boot Interview Questions Set 2
Core Java Interview Questions Set -1
Docker interview question Set -1
Docker interview question Set -2
No comments:
Post a Comment