Day 21 Task: Docker Important interview Questions🐬

Day 21 Task: Docker Important interview Questions🐬

Docker Interview

  • Docker is a good topic to ask in DevOps Engineer Interviews, mostly for freshers. One must surely try these questions in order to be better in Docker

Questions & Answers

What is the Difference between an Image, Container and Engine?

Image vs Container vs Engine

1 . Image: Image is blueprint of container which means its contain application code, library and configuration files.(Think of it is a recipe)

2 . Container: A running instance of a image. Its isolated and lightweight with its own filesystem and processes.

3 . Engine: The software that builds, runs and manage Container based on the images.(Think of it that chef following the recipe to create the meal)

What is the Difference between the Docker command COPY vs ADD?

Copy vs Add

1 . Copy: Docker copies its files/directories from the build context to the image file system. Its only useful for including static content.

2 . Add: It is similar to copy command, but it is also handle unpacking compressed file automatically. (eg: tar.gz)

What is the Difference between the Docker command CMD vs RUN?

CMD vs. RUN

1 . CMD: It is the default command executed when the container starts.

2 . RUN: Its executes the command during the image build process.It is mostly used for Installing dependencies, Setting up the environment, etc.

How Will you reduce the size of the Docker image?

Reducing image size

1 . It is use for multi-stage builds the application in the temporary stage with unnecessary tools and then copy the final artifacts into the final images.

2 . Leverage the base image with minimal dependencies such as Alpine Linux or Scratch, etc.

Why and when to use Docker?

When to use docker

1 . Deploying micro-services architecture.

2 . Standardizing the application environment.

3 . Workflows with Continuous integration(CI) and continuous deployment(CD) in Jenkins.

4 . Simplifying application deployment and testing.

Explain the Docker components and how they interact with each other.

Docker Components and Interaction

1 . Docker file interact to provide instruction to build Docker images.

2 . Docker daemon interact with Docker container to build and run them.

3 . Docker registry interact with Docker images to store and share the container in private and public.

4 . Docker client interact with user interface to communicate with Docker daemon.

Explain the terminology: Docker Compose, Docker File, Docker Image, Docker Container?

Docker Terminology

1 . Docker compose is the tool which defines the running container with eases.

2 . Docker file is the component its instruct to build Docker image.

3 . Docker image is the blue print of container its contain application code, library and configuration file.

4 . Docker container is the running instance of container which is isolated with its own filesystem and processes.

In what real scenarios have you used Docker?

Real-world Docker Use Cases

1 . Running micro-service

2 . Deploying web-application

3 . Building and testing application in isolated environment.

4 . Simplifying development workflows (DevOps)

Docker vs Hypervisor?

Docker vs. Hypervisor

1 . Docker provide containerization, isolation process with the same OS kernel

2 . Hypervisor create a virtual machine (VMs) with its own OS. Its offers strong isolation with more resource-intensive.

What are the advantages and disadvantages of using docker?

Advantages of Docker

1 . Run the application across differnet environment.

2 . Container share its own OS kernel but isolated with each other.

3 . Easy deployment and scaling containerized application.

4 . Streamlines the deployment and testing workflows.

Disadvantages of Docker

1 . Required proper security measure to minimize container escape risks.

2 . It can impact to host system resource if not managed efficently.

What is a Docker namespace?

Docker Namespace

Its is virtualized layer that isolate the process, file system, network resource, etc.

What is a Docker registry?

Docker Registry

A repository for storing and sharing the Docker image. public registry like Docker hub or you can setup private registries.

What is an entry point?

Entry Point

The command specified in Dokerfile's ENTRY POINT instructure that executed when the container start.

How to implement CI/CD in Docker?

CI/CD with Docker

Integreating docker into CI/CD pipeline that allows you to build, testing and deploying containerized application in automated manner.

Will data on the container be lost when the docker container exits?

Data Persistence

Data within the conatiner is lost unless you use volume or bind-mount to persist data in the container.

What is a Docker swarm?

Docker Swarm

A container orchestration platform for managing and scaling Docker services across a cluster of machines.

What are the docker commands for the following

Docker Commands

1 .docker ps: View running containers

2 .docker run -d --name <name>: Run a container in detached mode with a specific name

3 .docker export <container_id>: Export a container's filesystem

4 .docker load -i <image.tar.gz>: Import an existing Docker image

5 .docker stop <container_id>: Stop a running container

6 .docker rm $(docker ps -a -q -f status=exited): Remove all stopped containers

7 .docker system prune -a: Remove unused networks, build caches, and dangling images


Happy Learning

Thanks For Reading! :)

-DevOpsParthu💝💥