Spread the love

DOCKER INTERVIEW QUESTIONS & ANSWERS

Docker Interview Question& Answer

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.

What are docker images?

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.

What is Docker Container?

Docker Containers are the ready applications created from Docker Images. Or you can say they are running instances of the Images and they hold the entire package needed to run the application. This happens to be the ultimate utility of the technology. 

What are the advantages of using Docker container?

  • Offers an efficient and easy initial set up
  • Allows you to describe your application lifecycle in detail
  • Simple configuration and interacts with Docker Compose.
  • Documentation provides every bit of information.
What is a DockerFile?

It is a text file that has all commands which need to be run for building a given image.

What is the docker command that lists the status of all docker containers?

In order to get the status of all the containers, we run the below command: docker ps -a

On what circumstances will you lose data stored in a container?

The data of a container remains in it until and unless you delete the container.

What is docker image registry?
  • 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.
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
What command can you run to export a docker image as an archive?

This can be done using the docker save command and the syntax is: docker save -o .tar

What command can be run to import a pre-exported Docker image into another Docker host?

This can be done using the docker load command and the syntax is docker load -i
<export_image_name>.tar

Can a paused container be removed from Docker?

No, it is not possible! A container MUST be in the stopped state before we can remove it.

What command is used to check for the version of docker client and server?
  • The command used to get all version information of the client and server is the docker version.
  • To get only the server version details, we can run docker version –format ‘{{.Server.Version}}’
Where are docker volumes stored in docker?

Volumes are created and managed by Docker and cannot be accessed by non-docker entities. They are stored in Docker host filesystem at /var/lib/docker/volumes/

What does the docker info command do?

The command gets detailed information about Docker installed on the host system. The information can be like what is the number of containers or images and in what state they are running and hardware specifications like total memory allocated, speed of the processor, kernel version, etc

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>

Can we use JSON instead of YAML while developing docker-compose file in Docker?

Yes! It can be used. In order to run docker-compose with JSON, docker-compose -f docker-compose.json up can be used.

Describe the lifecycle of Docker Container?

The different stages of the docker container from the start of creating it to its end are called the docker container life cycle. 
The most important stages are:

  • Created:This is the state where the container has just been created new but not started yet.
  • Running:In this state, the container would be running with all its associated processes.
  • Paused:This state happens when the running container has been paused.
  • Stopped:This state happens when the running container has been stopped.
  • Deleted:In this, the container is in a dead state.
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.

How to check for Docker Client and Docker Server version?

The following command gives you information about Docker Client and Server versions:

$ docker version

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 in

How to start, stop and kill a container?

The following command is used to start a docker container:

$ docker start

and the following for stopping a running container:

$ docker stop

kill a container with the following command:

$ docker kill

Once you’ve worked with an image, how do you push it to docker hub?

$ docker push <username/image name>

How to delete a stopped container?

Use the following command to delete a stopped container:

$ docker rm <container id>

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.

What are the steps for the Docker container life cycle?

Below are the steps for Docker life cycle:

  • Build
  • Pull
  • Run

What are the three components of Docker Architecture

  • Client
  • Docker-Host
  • Registry

What is client?

Docker provides Command Line Interface tools to the client to interact with Docker daemon.

What is the purpose of Docker_Host?

It contains container, images, and Docker daemon. It offers a complete environment to execute and run your application.

 List out some important advanced docker commands

Command

Description

docker info

Information Command

docker pull

Download an image

docker stats

Container information

Docker images

List of images downloaded

What is the purpose of Docker_Host?

It contains container, images, and Docker daemon. It offers a complete environment to execute and run your application.

What the states of Docker container?

Important states of Docker container are:

  • Running
  • Paused
  • Restarting
  • Exited

What is the purpose of Docker_Host?

It contains container, images, and Docker daemon. It offers a complete environment to execute and run your application.

What is 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.

Scroll to Top