Question: What is Docker?
Answer :
Docker provides a container for managing software workloads on
shared infrastructure, all
while keeping them isolated from one another.
Docker is a tool designed to make it easier to create, deploy,
and run applications by using
Containers allow a developer to package up an application with
all of the parts it needs,
such as libraries and other dependencies and ship it all out as one
package.
By doing so, the developer can rest assured that the application
will run on any other Linux
machine regardless of any customized settings that machine might
have that could differ
from the machine used for writing and testing the code. In a
way, Docker is a bit like a
virtual machine. But unlike a virtual machine, rather than
creating a whole virtual operating
system. Docker allows applications to use the same Linux kernel
as the system that they're
running on and only requires applications be shipped with things
not already running on the
host computer. This gives a significant performance boost and
reduces the size of the
application.
Question: What Are Linux Containers?
Answer :
Linux containers, in short, contain applications in a way that
keep them isolated from the
host system that they run on.
Containers allow a developer to package up an application with
all of the parts it needs,
such as libraries and other dependencies, and ship it all out as
one package.
And they are designed to make it easier to provide a consistent
experience as developers
and system administrators move code from development
environments into production in a
fast and replicable way.
Please Click on Download button to download this questions for your easy reference.
Question: Who Is Docker For?
Answer :
Docker is a tool that is designed to benefit both developers and
system administrators,
making it a part of many DevOps (developers + operations) toolchains.
For developers, it means that they can focus on writing code
without worrying about
the system that it will ultimately be running on.
It also allows them to get a head start by using one of
thousands of programs already
designed to run in a Docker container as a part of their
application.
For operations staff, Docker gives flexibility and potentially
reduces the number of systems
needed because of its small footprint and lower overhead.
Question: What Is Docker Container?
Answer :
Docker containers include the application and all of its
dependencies, but share the kernel
with other containers, running as isolated processes in user
space on the host operating
system.
Docker containers are not tied to any specific infrastructure:
they run on any computer, on
any infrastructure, and in any cloud.
Now explain how to create a Docker container, Docker containers
can be created by either
creating a Docker image and then running it or you can use
Docker images that are present
on the Dockerhub. Docker containers are basically runtime
instances of Docker images.
Question: What Is Docker Image?
Answer :
Docker image is the source of Docker container. In other words,
Docker images are used
to create containers. Images are created with the build command,
and they’ll produce a container when started with run.
Images are stored in a Docker registry such as
registry.hub.docker.com because they can
become quite large, images are designed to be composed of layers
of other images,
allowing a minimal amount of data to be sent when transferring
images over the network.
Question: What Is Docker Hub?
Answer :
Docker hub is a cloud-based registry service which allows you to
link to code repositories,
build your images and test them, stores manually pushed images,
and links to Docker
cloud so you can deploy images to your hosts.
It provides a centralized resource for container image
discovery, distribution and change
management, user and team collaboration, and workflow automation
throughout the
development pipeline.
Please Click on Download button to download this questions for your easy reference.
Question: What is Docker Swarm?
Answer :
Docker Swarm is native clustering for Docker. It turns a pool of
Docker hosts into a single,
virtual Docker host.
Docker Swarm serves the standard Docker API, any tool that
already communicates with a
Docker daemon can use Swarm to transparently scale to multiple
hosts.
Question: Explain basic Docker usage workflow
Answer :
ร Everything starts with the Dockerfile. The Dockerfile is
the source code of the Image.
ร Once the Dockerfile is created, you build it to create
the image of the container. The image is just the "compiled version"
of the "source code" which is the Dockerfile.
ร Once you have the image of the container, you should
redistribute it using the registry. The registry is like a git repository --
you can push and pull images.
ร Next, you can use the image to run containers. A running
container is very similar, in many aspects, to a virtual machine (but without
the hypervisor).
Questions: What is Dockerfile used for?
Answer :
A Dockerfile is a text document that contains all the commands a
user could call on the
command line to assemble an image.
Using docker build users can create an automated build that
executes several commandline
instructions in succession.
Question: How is Docker different from other container
technologies?
Answer :
Docker containers are easy to deploy in a cloud. It can get more
applications running on the
same hardware than other technologies.
It makes it easy for developers to quickly create, ready-to-run
containerized applications
and it makes managing and deploying applications much easier.
You can even share
containers with your applications.
Question: How to create Docker container?
Answer :
We can use Docker image to create Docker container by using the
below command:
docker run -t -i command name
This command will create and start a container. You should also
add, If you want to check
the list of all running container with the status on a host use
the below command:
docker ps -a
Question: How to stop and restart the Docker container?
Answer :
In order to stop the Docker container you can use the below
command:
docker stop container ID
Now to restart the Docker container you can use:
docker restart container ID
Question: How do you scale your Docker containers?
Answer :
The Docker containers can be scaled to any level starting from a
few hundreds to even thousands or millions of containers. The only condition is
that the containers need the memory and the OS at all times and there should
not be a constraint on these when the Docker is getting scaled.
Please Click on Download button to download this questions for your easy reference.
Question: What is the difference between the COPY and ADD
commands in a Dockerfile?
Answer :
Although ADD and COPY are functionally similar, generally
speaking, COPY is preferred.
That’s because it’s more transparent than ADD. COPY only
supports the basic copying of local files into the container, while ADD has
some features (like local-only tar extraction and remote URL support) that are
not immediately obvious. Consequently, the best use for ADD is local tar file
auto-extraction into the image, as in ADD rootfs.tar.xz /.
Question: What is the difference between docker run and docker
create?
Answer :
The primary difference is that using ‘docker create’ creates a
container in a stopped state.
Bonus point: You can use ‘docker create’ and store an outputed
container ID for later
use. The best way to do it is to use ‘docker run’ with --cidfile
FILE_NAME as running it
again won’t allow to overwrite the file.
Question: What four states a Docker container can be in?
Answer :
Running
Paused
Restarting
Exited
Question: What Is Difference Between Repository and a Registry?
Answer :
Docker registry is a service for hosting and distributing
images. Docker repository is a
collection of related Docker images.
Question: What platforms does Docker run on?
Answer :
Docker runs on only Linux and Cloud platforms and below are the vendors
of Linux:
v Ubuntu 12.04, 13.04 et al
v Fedora 19/20+
v RHEL 6.5+
v CentOS 6+
v Gentoo
v ArchLinux
v openSUSE 12.3+
v CRUX 3.0+
Cloud:
v Amazon EC2
v Google Compute Engine
v Microsoft Azure
v Rackspace
Question: What are the most common instructions in Dockerfile?
Answer :
Some of the common instructions in Dockerfile are as follows:
FROM: We
use FROM to set the base image for subsequent instructions. In every valid
Dockerfile, FROM is the first instruction.
LABEL: We use LABEL to organize our images as per project, module,
licensing etc. We can also use LABEL to help in automation.
In LABEL we specify a key value pair that can be later used for
programmatically handling the Dockerfile.
RUN: We
use RUN command to execute any instructions in a new layer on top of the
current image. With each RUN command we add something on top of the image and
use it in subsequent steps in Dockerfile.
CMD: We
use CMD command to provide default values of an executing container. In a
Dockerfile, if we include multiple CMD commands, then only the last instruction
is used.
Question: How to link containers?
Answer :
The simplest way is to use network port mapping. There’s also
the - -link flag which is
deprecated.
Please Click on Download button to download this questions for your easy reference.
Question: How will you monitor Docker in production?
Answer :
Docker provides tools like docker stats and docker events to
monitor Docker in production. We can get reports on important statistics with
these commands.
Docker stats: When we call docker stats with a container id, we get the CPU,
memory usage etc of a container. It is similar to top command in Linux.
Docker events: Docker events are a command to see the stream of activities
that are going on in Docker daemon.
Some of the common Docker events are: attach, commit, die,
detach, rename, destroy etc. We can also use various options to limit or filter
the events that we are interested in.
Question: What is the difference between Docker RUN, CMD and ENTRYPOINT?
Answer :
A CMD does not execute anything at build time, but specifies the
intended command for
the image.
RUN actually runs a command and commits the result.
If you would like your container to run the same executable
every time, then you should
consider using ENTRYPOINT in combination with CMD.
Question: How many containers can run per host?
Answer :
As far as the number of containers that can be run, this really
depends on your
environment. The size of your applications as well as the amount
of available resources will
all affect the number of containers that can be run in your environment.
Containers unfortunately are not magical. They can’t create new
CPU from scratch. They
do, however, provide a more efficient way of utilizing your
resources.
The containers themselves are super lightweight (remember,
shared OS vs individual OS
per container) and only last as long as the process they are
running. Immutable
infrastructure if you will.
Question: What is Docker hub?
Answer :
Docker hub is a cloud-based registry service which allows you to
link to code repositories,
build your images and test them, stores manually pushed images,
and links to Docker
cloud so you can deploy images to your hosts.
It provides a centralized resource for container image
discovery, distribution and change
management, user and team collaboration, and workflow automation
throughout the
development pipeline.
Please Click on Download button to download this questions for your easy reference.