0% found this document useful (0 votes)
2 views4 pages

Docker_Interview_Questions_Solutions

The document contains a series of practice questions and answers related to Docker, covering topics such as advantages of Docker, Dockerfile, Docker images, commands for managing containers, and networking. It also discusses Docker components, security practices, and orchestration tools like Kubernetes and AWS EKS. Additionally, it includes practical tasks for writing Docker Compose files and Dockerfiles for specific use cases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views4 pages

Docker_Interview_Questions_Solutions

The document contains a series of practice questions and answers related to Docker, covering topics such as advantages of Docker, Dockerfile, Docker images, commands for managing containers, and networking. It also discusses Docker components, security practices, and orchestration tools like Kubernetes and AWS EKS. Additionally, it includes practical tasks for writing Docker Compose files and Dockerfiles for specific use cases.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

****THIS QUESTIONS ARE ONLY FOR PRACTISE.

DONT CONSIDER THIS AS INTERVIEW


QUESTIONS. YOU NEED TO STUDY FROM YOUR SIDE AS WELL. THIS ARE ONLY FOR OUR
PREPARATION.

1.what are the advantages of using docker ? why we use docker ? which
containerization tool you have used in your organization ?
- cost saving since we will create container only with the amout of ram and cpu
required to run that microservice.
- Rapid deployment
- same docker image can be used on multicloud platform
- more secure.

2. how to reduce the docker image size ?


- use multistage concept
- smaller base images (lightweight images like alpine)
- reduce the number of layers.( instead of adding multiple run instruction use only
one time RUN instruction and write evrything infront of it)
- ignore unwanted files using dockerignore

2.what is dockerfile ?
-- docker file is a simple textfile that carries the detail information using
which docker image will be created.we write dockerfile using different
instructions.
Dockerfile includes information like operating system details , executing any
commands , downloading packages , dependencies etc.

3.what is docker image ?


-- 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
spin up there to run the application.

4.what are the different instructions you have used to write docker file ?
A.FROM: This is used to set the base image for upcoming instructions. "A docker
file is considered to be valid if it starts with the FROM instruction"
B.LABEL: This is used for the image organization based on projects, modules, or
licensing.
C.RUN: When we want to execute the commands
D.CMD: This command is used to provide default values of an executing container. In
cases of multiple CMD commands the last instruction would be considered.
ENTRYPOINT : this also gets executed when container gets created.
EXPOSE
MAINTAINER
USER
WORKDIR
VOLUME

5.diff between ADD & COPY ?


-- COPY provides just the basic support of copying local files into the container
-- ADD provides additional features like remote URL ( downloading packages from
internet ) and tar extraction support.

6.diff between CMD & ENTRYPOINT


CMD : gets executed when container weill be created. it can be override.
ENTRYPOINT : gets executed when container is created. priority of ENTRYPOINT Is
high. cannot be override.
7.Suppose i want to do all activities using some specific user , which instruciton
you will use ?
USER

8.what is port forwarding / port mapping in docker ?


** HOPE YOU REMEMBER THE COMMAND

9.how you will login into existing docker container ?


** HOPE YOU REMEMBER THE COMMAND

10.how to take backup image of any running container ?


** HOPE YOU REMEMBER THE COMMAND

11.command to check all running container ?


docker ps -l

12.command to check all container ( running and stop both) ?


docker ps -la

13.can we delete running container ?


- we can delete it forcefully but its not good practise. we must stop the
container and we should delete it.

14.where do you store your docker images ?


we store on dockerhub.

15.if docker hub then how you push your images ?


** HOPE YOU REMEMBER THE COMMAND

17.what is docker lifecycle ?


--- 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:

A.Created: This is the state where the container has just been created new but not
started yet.
B.Running: In this state, the container would be running with all its associated
processes.
C.Paused: This state happens when the running container has been paused.
D.Stopped: This state happens when the running container has been stopped.
E.Deleted: In this, the container is in a dead state.

18.where do you store the data of your containers ?


- we use persistent volume.
- They are stored in Docker host filesystem at /var/lib/docker/volumes/

19.command to create docker volume ?


** HOPE YOU REMEMBER THE COMMAND

20.Diff types of network drivers ? explain them ?


- Bridge network - this is by default network which gets used.
- local - this is generally used when we want to assign same IP address to
container as that of local machine.
- null - It means there will be no IP address to contianer.No internet
access. cannot be access from outside the server. this is used only for testing
purpose.

21.Which orhestration tool you know ?


There are different orchestration tools like AWS rancher kubernetes. I have used
Kubernetes. for deploying cluster on AWS, i used AWS EKS service.

22. Have you used AWS ECS service ?


No. i have used AWS EKS service for deploying the microservices on Kubernetes
cluster.

23. what is docker daemon ?


The Docker daemon ( dockerd ) listens for Docker API requests and manages Docker
objects such as images, containers, networks, and volumes.

24. what is docker-compose ? have you used it in your organization ?


It is a YAML file consisting of all the details regarding various services,
networks, and volumes that are needed for setting up the Docker-based application.
So, docker-compose is used for creating multiple containers, host them and
establish communication between them. For the purpose of communication amongst the
containers, ports are exposed by each and every container.

I have used this mostly when we are doing testing. we need to create again and
again same containers so our developers , testers can do their testing. so i use
docker-compose to create those container. this saves my time.

25. What is docker image registry? which tools do you use in your organization to
store docker images ?
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.
some other tools are - AWS ECR , Nexus

26. Why you store images on dockerhub and not on AWS ECR ?
- AWS ECR is private repository which can be used only for AWS. in our company
there are different projects running on different cloud hence we use dockerhub.
- this makes easy for everyone to pull the docker images.

27. what you do for security of dockerimages ?


- we use the concept of trivy scanner. this scans our docker images. if we find
some vulnerabilities then we clear them and then only we push our docker image to
coker hub

28. How many Docker components are there?


-- There are three docker components, they are - Docker Client, Docker Host, and
Docker Registry.

A.Docker Client: This component performs “build” and “run” operations for the
purpose of opening communication with the docker host.
B.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.
C. 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.

29.Can you tell the differences between a docker Image and Layer?
-- Image: This is built up from a series of read-only layers of instructions. An
image corresponds to the docker container and is used for speedy operation due to
the caching mechanism of each step.

-- Layer: Each layer corresponds to an instruction of the image’s Dockerfile. In


simple words, the layer is also an image but it is the image of the instructions
run.

30. How will you ensure that a container 1 runs before container 2 while using
docker compose?

- The “depends_on” parameter helps us to do it.

]version: "2.4"
services:
backend:
build: .
depends_on:
- db
db:
image: postgres

31. command to create docker image , docker container


** HOPE YOU KNOW THE COMMAND

****** PRACTICAL QUESTIONS :


- Genrally interviewer ask below practical Questions ( you need to share your
screen and write down )
1. write down any docker compose file to launch multiple containers .
2. write dockerfile to create a container inside which you need to install
apache. also copy python script from local machine to that container.

You might also like