0% found this document useful (0 votes)
33 views6 pages

Docker Important Interview Questions

Docker Important Interview Questions

Uploaded by

manishal45667
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views6 pages

Docker Important Interview Questions

Docker Important Interview Questions

Uploaded by

manishal45667
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Docker Important Interview Questions

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

An image is a package that contains all the necessary components to run software. It is similar to a
snapshot of a container. A container is a running instance of an image. It acts like a virtual machine
that executes the software specified in the image. The engine is the part that handles the
containers. It is responsible for starting, stopping, and managing the containers.

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

The COPY command is used to copy files or directories from the build context (the directory where
the Dockerfile is located) into the container during the build process. The ADD command is also
used for copying files or directories from the build context into the container during the build
process, but it additionally allows you to specify a different name for the file or directory in the
container.

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

The CMD command is used to set a default command to run when a container starts. The RUN
command is used to execute a command during the container build process. It is commonly used to
configure the container environment or install software.

💡 How Will you reduce the size of the Docker image?

There are several ways to reduce the size of a Docker image:

Use the Dockerfile's BUILD instruction to only include the necessary files and directories in the
image.

Use the Dockerfile's COPY instruction to copy only the necessary files and directories into the
image.

Use the Dockerfile's ENTRYPOINT instruction to set the default command that should be run
when the container is started.

Docker Important Interview Questions 1


Use the Dockerfile's VOLUME instruction to mount a volume that contains data that should be
preserved across container restarts.

Use the Dockerfile's EXPOSE instruction to expose a port that should be accessible from
outside the container.

💡 Why and when to use Docker?

Benefits of Docker:

Isolation: Docker enables running applications in isolated containers, preventing interference


with other applications on the same host.

Portability: Docker containers are portable and can be run on any Docker-supported host,
regardless of the operating system or architecture.

Efficiency: Docker containers consume fewer resources compared to traditional virtual


machines, enabling quick and easy startup.

Flexibility: Docker facilitates the creation, modification, and deletion of containers as required.

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

The Docker components are:

Docker Engine: This manages the containers. It runs, stops, and manages them.

Docker Hub: This is a cloud-based registry for storing and sharing Docker images.

Docker Compose: This tool helps define and run multi-container Docker applications.

Docker File: This is a text file with instructions for building a Docker image.

Docker Image: This is a lightweight, standalone, and executable package that has everything
needed to run software.

Docker Container: This is a running instance of a Docker image.

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

Docker Compose: This is a tool that allows you to define and run multi-container Docker
applications. It provides a YAML configuration file that defines the services, networks, and volumes
for the application.

Docker Important Interview Questions 2


Docker File: This is a text file that contains instructions for building a Docker image. It includes
instructions for copying files, setting environment variables, and running commands.

Docker Image: This is a lightweight, standalone, and executable package that includes everything
needed to run a piece of software. It's like a snapshot of a container.

Docker Container: This is a runtime instance of a Docker image. It's like a virtual machine that runs
the software defined in the image.

💡 In what real scenarios have you used Docker?

I've used Docker in a variety of scenarios, including:

Building and deploying web applications

Creating development environments for software development

Running batch processing jobs

Creating CI/CD pipelines

Deploying microservices

Testing and validating software

💡 Docker vs Hypervisor?

Docker and hypervisors are both used to run isolated environments, but they differ in their approach
and functionality:

Docker utilizes the host operating system's kernel and runs the containers in user space.

Hypervisors, on the other hand, employ a separate kernel and run the virtual machines in kernel
space.

Docker is lightweight and efficient compared to hypervisors, but it is also less secure. Hypervisors
offer better isolation and security, but they are more resource-intensive.

💡 What are the advantages and disadvantages of using docker?

Advantages:

Isolation: Docker provides stronger isolation than regular virtual machines.

Portability: Docker containers can be moved and run on any host that supports Docker.

Docker Important Interview Questions 3


Efficiency: Docker containers use fewer resources compared to regular virtual machines.

Flexibility: Docker allows you to easily create, modify, and delete containers as needed.

Disadvantages:

Security: Docker is less secure than hypervisors because it runs in the user space.

Performance: Docker containers may not perform as well as regular virtual machines.

Complexity: Docker can be complicated to set up and manage, especially for large-scale
applications.

💡 What is a Docker namespace?

A Docker namespace is a method to group related Docker objects, like containers, images, and
networks, into one unit. This helps you manage and separate the objects more easily.

💡 What is a Docker registry?

A Docker registry is a central location where Docker images are stored. It allows you to store, share,
and manage Docker images.

💡 What is an entry point?

An entry point is a command that is run when a Docker container is started. It's specified in the
Dockerfile using the ENTRYPOINT instruction.

💡 How to implement CI/CD in Docker?

To implement CI/CD in Docker, you can use tools like Jenkins, Travis CI, or CircleCI to automate the
build, test, and deployment process. These tools allow you to define workflows that include steps for
building Docker images, running tests, and deploying the images to a registry.

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

Docker Important Interview Questions 4


Yes, data on a Docker container will be lost when the container exits, unless you specify a volume
to persist the data. A volume is a directory that is shared between the host and the container, and it
persists even after the container is deleted.

💡 What is a Docker swarm?

A Docker swarm is a cluster of Docker nodes that work together to run and manage Docker
containers. It allows you to scale your applications horizontally and manage the containers more
efficiently.

💡 What are the docker commands for the following:

View running containers: docker ps

Run a container under a specific name: docker run -d --name <name> <image>

Export a Docker image: docker save <image> > <file>

Import an already existing Docker image: docker load <file>

Delete a container: docker rm <container>

Remove all stopped containers, unused networks, build caches, and dangling images: docker system prune -a

💡 What are the common docker practices to reduce the size of Docker Image?

Some common practices to reduce the size of a Docker image include:

Using the Dockerfile's BUILD instruction to only include the necessary files and directories in the
image.

Docker Important Interview Questions 5


Using the Dockerfile's COPY instruction to copy only the necessary files and directories into the
image.

Using the Dockerfile's ENTRYPOINT instruction to set the default command that should be run
when the container is started.

Using the Dockerfile's VOLUME instruction to mount a volume that contains data that should be
preserved across container restarts.

Using the Dockerfile's EXPOSE instruction to expose a port that should be accessible from
outside the container.

Docker Important Interview Questions 6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy