Day 21 - #90daysofdevopschallenge
Docker Interview Questions

Nikhil Patil
π¨βπ» I love Linux & DevOps! π»
π§ Linuxπ¨βπ» | DevOps & Cloud Enthusiast | π Azure Admin | π οΈ Ansible | π Git | π³ Docker | π OpenLDAP | π₯οΈ System Admin | | π Jenkins π οΈ
π Pune
π I'm really into using and managing computers with Linux. I also like making things work smoothly and quickly.
π I work with Microsoft Azure, use tools like Ansible and Git to automate tasks, and make software run in containers with Docker.
π I handle access and security using OpenLDAP, and I'm all about keeping systems running smoothly.
π Exploring opportunities in cloud and DevOps.
π§ Get in touch: nikrpatil1997@gmail.com
π Introduction
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 at Docker.
π Docker Questions
What is the Difference between an Image, Container, and Engine?
Image - An image contains all the necessary files, libraries, and configurations needed to run the application.
Container - An instance of an image is called a container. takes an image and turns it into a running instance of that application.
Engine - The engine is the core software that manages containers and allows them to run. The engine takes care of starting, stopping, and managing containers, so you can focus on your applications.
What is the Difference between the Docker command COPY vs ADD?
COPY - is like moving things from your computer to the container. It's simple and efficient for copying local files into your container.
ADD - ADD command does more than just copy files. It can also handle URLs and automatically extract compressed files.
What is the Difference between the Docker command CMD vs RUN?
RUN- This command is used to run commands during the process of building a Docker image.
CMD - This command is used to specify what command should be run when a container based on the image starts running.
How Will you reduce the size of the Docker image?
Start with a smaller and more lightweight base image. Remove unused files and temporary files. Some commands are lighter than others. Choose efficient ones when possible. Only include libraries and dependencies your app truly needs. Delete temporary files and clear caches within the Dockerfile to make the image smaller.
Why and when to use Docker?
Docker helps you package up your software and all its parts (libraries) into a single container. If you want to share your software with others and make sure it runs exactly the same way on their computers. When you need to quickly create and run more copies of your app, like when your users increase.
Explain the Docker components and how they interact with each other.
Image - An image contains all the necessary files, libraries, and configurations needed to run the application.
Container - An instance of an image is called a container. takes an image and turns it into a running instance of that application.
Dockerfile: It's a text file that gives instructions to create an image. It lists the software and steps to follow.
Registry: A registry is a library where you store and share your images with others. Docker Hub is a famous example.
Explain the terminology: Docker Compose, Docker File, Docker Image, Docker Container?
Docker Compose - It helps you organize and manage multiple Docker containers together. You describe how they should work together in a single file.
Dockerfile - It's a text file that tells Docker exactly what software to use and how to mix them to create a Docker image
Docker Image - An image contains all the necessary files, libraries, and configurations needed to run the application.
Docker Container - An instance of an image is called a container. takes an image and turns it into a running instance of that application.
In what real scenarios have you used Docker?
Yes used a docker container to install the OpenLDAP tool in the container rather than installing it on the base system.
Docker vs Hypervisor?
Docker - Docker lets you pack up an application and all its needed stuff into a single box. This box, called a container, can run the app consistently on different computers.
Hypervisor - It's software that lets you run multiple operating systems (like Windows and Linux) on the same computer. Each operating system runs in its own separate space, unaware of the others.
What are the advantages and disadvantages of using docker?
Advantages -
Apps are separate from each other and the system.
They use less memory and CPU.
Apps run the same on different computers.
Changes can be made without affecting other apps.
Disadvantages -
Docker files can be big and slow to download.
Mistakes can expose apps to risks.
Saving data can be complex.
What is a Docker namespace?
Docker namespaces help keep different parts of a software application separate from each other.
What is a Docker registry?
A Docker registry is like that special place for storing containers. This registry acts as a central location where you can store and manage your containers.
What is an entry point?
An entry point refers to a specific command that you can set for a container. It's like telling Docker what the main thing is that the container should do when it starts running.
How to implement CI/CD in Docker?
The CI/CD is a continuous integration and Continuous deployment can achieve by taking code from git and triggering the pipeline it will do the task as per the pipeline and create docker containers with the help of docker-compose.
Will data on the container be lost when the docker container exits?
No, if you exit from the container data in the container is still available in the container.
What is a Docker swarm?
A Docker Swarm is a tool that lets you manage and orchestrate a group of Docker containers as a single system. It's like having a manager for your containers that helps them work together smoothly.
What are the docker commands for the following:
view running containers
docker ps
command to run the container under a specific name
docker run --name <name> <img_name>
command to export a docker
docker export <container_name> <output_file.tar>
command to import an already existing docker image
docker import <input_file.tar>
commands to delete a container
docker rm <container_name>
command to remove all stopped containers, unused networks, build caches, and dangling images?
docker system prune --all




