Docker Interview Question
1. What is Docker container?
Answer: Docker container helps in running the application smoothly. Essentially, it is a software unit that contains the code and all its dependencies – system tools, libraries, settings – everything you need to run the application.
2. Explain Docker Registry in detail.
Docker images are stored in the Docker registry, which serves as the default image storage. This is an important storage area that is maintained regularly as it contains container images. Another public registry is Docker Cloud.
Briefly explain the Docker container lifecycle.
3. The Docker container lifecycle consists of the following:
- container making
- running container
- stopping the container
- opening the container
- starting the container
- stopping the container
- restarting the container
- destroying the container
- destroying the container
4. Explain some important Docker commands.
Some important Docker commands include the following:
- Build: Builds an image file for Docker
- create: creates a new container
- kill: kill a container
- dockerd: Launches the Docker daemon
- Commit: Creates a new image from container changes
5. What are namespaces?
Docker namespaces provide an isolated workspace in the form of a container. Docker creates namespaces for containers after they are started, which provides a layer of isolation. Each container has its own unique namespace.
6. What is Docker Swarm?
Docker Swarm is an important tool used to cluster and schedule Docker containers. This makes it easier to create and maintain nodes in Docker or a single VS.
7. How do you identify the status of a Docker container?
Use the following command to return the status of each Docker container:
“docker ps -a.”
This command will return a list of all available Docker containers along with their status on the host. From the list, one can easily find the desired container to check its status.
8. What are Docker images and run commands?
Docker images are sets of files that enable instances to be built and run in separate containers. Each example is a different process.
Images are created using the information necessary to run an executable application.
You can use the docker run command to create and start a container instance using a Docker image. If an image is running, it can be attached to any number of instances (or containers).
9. What are the workings and applications of Docker?
Following are some of the functionalities and applications of Docker:
- Easy configuration at infrastructure level
- Helps the developer to focus exclusively on business logic as it reduces development time, thereby increasing productivity.
- Enhances debugging capabilities
- Allows to isolate an application
- Containerization reduces the need for multiple servers.
- Provides faster deployment at the OS level
10. What are Docker objects?
- Docker images, services, and containers are called Docker objects.
- Image: Contains instructions for creating a Docker container
- Container: a runnable instance of an image
- Service: scaling containers on different Docker daemons as a swarm
Other Docker objects include networks and volumes.
11. Which is more suitable for a Docker container: a stateless or stateful application?
Stateless applications are more suitable for Docker containers because we can create a single, reusable container for our application, which allows us to separate state configuration from the app and the container.
By doing this, we can run multiple instances of the same container with different production parameters etc.
12. What is Dockerfile used for?
A Dockerfile contains a series of instructions to build an image that can be used to initialize a container. This text document contains every command you would enter at the command line to create an image.
13. What networks are available by default in Docker?
Default available networks include:
Bridge: The default network to which containers will connect if network is not otherwise specified.
None: Connects to a container-specific network stack that does not have a network interface.
Host: Connects to the host’s network stack
14. How is Docker monitored in production?
When running Docker in production, essential statistics can be collected and examined using tools such as Docker Stats and Docker Events.
Docker stats can be called from within a container to return data related to the container’s CPU and memory usage. It is similar to the Linux top command which can be used to check all running processes and their current computational load.
Docker events represent a list of commands that can be used to analyze any ongoing activities being processed by the Docker daemon. These commands include attach, commit, rename, destroy, and die.
15. Shed some light on Docker’s workflow.
Here’s a quick overview of Docker’s workflow:
Everything starts with the source code of the Dockerfile, the image Once created, the Dockerfile helps build the container image, which is a compiled version of the Dockerfile. After this, it is redistributed through the registry and used to run the container.
16. What is the difference between docker run and docker create?
If you use docker create, the container is created in a ‘stopped’ state. This allows you to store and output the container ID later. If you use ‘docker run’ with —cidfile FILE_NAME , it will not allow you to overwrite the file.
17. What is Virtualization?
Initially, virtualization enabled the logical partitioning of mainframe systems to enable multiple applications to run at the same time on a single system. As technology progressed, the meaning of the term evolved to represent the running of multiple (and possibly different) operating systems (OS) on an individual x86 system.
Nowadays, the term is broadly used to refer to the process of running multiple OSes on the same hardware. In this scenario, the primary OS acts as the administrator, and the guests must follow pre-defined procedures for bootstrapping, loading the kernel, etc. This ensures greater security and prevents the guest system from gaining full system access, which could lead to a data breach.
There are three types of virtualization:
- paravirtualization
- emulation
- Container-Based Virtualization
18. What is the difference between registry and repository?
The Docker registry hosts and distributes images and Docker Hub is the default registry. A Docker repository (or repo) allows you to store a collection of Docker image versions. This means that the images will have the same names, but their tags will be different to reflect different versions.
19. What are some basic Docker commands?
Some basic Docker commands are:
- docker Push: Pushes a repository or image to the registry
- docker run: runs a command in a new container
- docker pull: pulls the repository or image from the registry
- docker start: Starts one or more containers.
- docker stop: stops one or more running containers
- docker Search: Searches for an image in Docker Hub
- docker commit: creates a new image
20. What are Docker Image, Docker Hub and Docker File?
Docker images: These multi-layer files are used to create instances of Docker containers, and are created using terminal command directives or a pre-defined Dockerfile that includes each of these directives. Using an image can speed up Docker build times due to caching at each step of the build sequence.
Docker Hub: This is a service provided by Docker that can be used to find and share Docker images with others in a team. Just as GitHub is used to provide a distributed file store (with version control), Docker Hub allows you to push and pull images, access private repos that store Docker images, and use GitHub or BitBucket repositories. Allows to auto-build Docker images. Before sending these to Docker Hub.
Dockerfile: This is a text document used to store build instructions for a Docker image. When run, Docker automatically executes commands for an image.
Read Also – Running Maven build with Jfrog Artifactory
Tag –
Docker Interview Question Docker Interview Question Docker Interview Question Docker Interview Question Docker Interview Question Docker Interview Question
- Deployment of vault HA using MySQL - September 18, 2024
- Sending slack notification via pipeline job - August 25, 2024
- SonarQube integration with Jenkins - August 24, 2024