Docker_Interview_Questions_Solutions
Docker_Interview_Questions_Solutions
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.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.
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
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.
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.
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.
30. How will you ensure that a container 1 runs before container 2 while using
docker compose?
]version: "2.4"
services:
backend:
build: .
depends_on:
- db
db:
image: postgres