Docker is a
tool that enables you to create, deploy, and manage lightweight, stand-alone
packages that contain everything needed to run an application (code, libraries,
runtime, system settings, and dependencies). These packages are called
containers.
Each
container is deployed with its own CPU, memory, block I/O, and network
resources, all without having to depend upon an individual kernel and operating
system. While it may be easiest to compare Docker and virtual machines, they
differ in the way they share or dedicate resources.
Docker
Engine
Docker Engine is a client-server application with these major
components:
·
A server which is a type of long-running program called a daemon process.
·
A
REST API which specifies interfaces that programs can use to talk to the daemon
and instruct it what to do.
·
A
command-line interface (CLI) client.
The CLI uses the Docker REST API to control or interact with the
Docker daemon through scripting or direct CLI commands. Many other Docker
applications use the underlying API and CLI.
Docker files
A
Docker file is
a text file that contains the necessary commands to assemble an image. Once a
Docker file is written, the administrator uses the docker build command to create an image-based
on the commands within the file. The commands and information within the Docker file can
be configured to use specific software versions and dependencies to ensure
consistent and stable deployments.
A Docker file
uses the following commands for building the images:
- ADD -
copy files from a source on the host to the container’s own filesystem at
the set destination.
- CMD -
execute a specific command within the container.
- ENTRYPOINT - set
a default application to be used every time a container is created with
the image.
- ENV - set
environment variables.
- EXPOSE -
expose a specific port to enable networking between the container and the
outside world.
- FROM -
define the base image used to start the build process.
- MAINTAINER -
define the full name and email address of the image creator.
- RUN -
central executing directive for Docker files.
- USER - set
the UID (the username) that will run the container.
- VOLUME -
enable access from the container to a directory on the host machine.
- WORKDIR - set the path where the command, defined with CMD, is to be executed.
Docker
architecture
Docker uses a client-server architecture. The Docker client talks to the Docker daemon,
which does the heavy lifting of building, running, and distributing your Docker
containers. The Docker client and daemon can run on the same
system, or you can connect a Docker client to a remote Docker daemon. The
Docker client and daemon communicate using a REST API, over UNIX sockets or a
network interface.
The Docker daemon
The Docker daemon listens for Docker API
requests and manages Docker objects such as images, containers, networks, and
volumes. A daemon can also communicate with other daemons to manage Docker
services.
The
Docker client
The Docker client is the primary way
that many Docker users interact with Docker. When you use commands such
as
docker
run, the client
sends these commands to docker,
which carries them out. The docker command
uses the Docker API. The Docker client can communicate with more than one
daemon.
Docker
registries
A Docker registry stores Docker images. Docker Hub is a public registry that anyone can use, and Docker is
configured to look for images on Docker Hub by default. You can even run your
own private registry. If you use Docker Datacenter (DDC), it includes Docker
Trusted Registry (DTR).
Docker
objects
When you use Docker, you are creating and using images,
containers, networks, volumes, plugins, and other objects. This section is a
brief overview of some of those objects.
