Docker is open source software for creating and managing containers. A container is different from Virtual Machine, while virtualization involves running many operating systems on a single system, the containers share the same operating system kernel and isolate the application processes from the rest of the system. which means it does not have an entire OS, only what is needed to run its applications(code, runtime, system tools, library, and settings).A docker container is built from an image, which corresponds to its configuration.



Docker Components

When users talk about Docker, it’s usually the open-source client-server application that forms the basis of the container platform. In Docker terminology, this is commonly referred to as the “Docker Engine”. The Docker engine is based on the Docker daemon , a REST API, and a Command Line Interface (CLI) for the user interface. This build allows you to deal with the engine through the command line and easily manage images, Docker files and containers from the terminal

Docker Client – Docker client key component which used by many Docker users to interact with Docker. When you run the docker commands, the client sends these commands to dockerd.

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

Docker Registry – The place where Docker images are stored.



Docker Terminologies 

A Docker container, unlike traditional virtual machines, does not require a separate operating system. Instead, it relies on the kernel features of the underlying operating system and uses resource isolation (CPU, memory, I / O, network connections, and so on).

Images are created from configuration files, called “Dockerfiles”, that describe exactly what needs to be installed on the system.A Docker image represents the file system, without the processes. It contains everything you have decided to install (Java, a database, a script that you will launch, etc …). A container is the execution of an image.

The Dockerfile is your source file that once compiled gives an image. A Dockerfile can be included in other Dockerfile, and be the basis of several different images. You can choose to use official images, modified images that you find on Docker Hub, or customize your own images by writing a Dockerfile.

Compose is a tool for defining and executing multi-container applications. Since containers are ideal for micro-service-based applications, it becomes apparent that the interconnection of multiple containers and the management of multi-containers must be done quickly.

Volumes are the most suitable mechanism for persisting data generated by and used by Docker containers. Docker volumes have many advantages, such as easy backup or migration, or easy management with Docker tools and commands.

Docker Swarm:
During production, two major constraints can emerge, scalability and availability of containers to ensure high availability. This aspect leads to a multiplication of containers and Docker hosts. It becomes difficult to manage all these elements in a simple way via the Docker client. This is where Docker Swarm comes in, which will simply orchestrate all operations.


Commonly used Docker commands

$ docker info  – Gives information about docker engine.
$ docker container run <image name>  –
Create a container based on the image. Ports can also be exposed with the same command.
$ docker container stop/start  <container-ID/container name> – Stops or starts the conatiner.
$ docker container ls/ps  – View active containers.
$ docker container ls/ps -a  – View all containers.
$ docker container rm <container-ID/container name>  – Delete an inactive/stoppped container.
$ docker container rm -f <container-ID/container name>  – Force deletion of an active/running container.
$ docker images ls  – List existing images.
$ docker image rmi <image-ID/image name>  – Delete docker image.
$ docker exec -t -i <container-ID/container name>  bash  – Execute commands in an active container.
$ docker inspect <container-ID/container name> – Inspect the configuration of a container.
$ docker build -t <image-ID/image name> .  – Build an image from a Dockerfile.
$ docker history <image-ID/image name>  – Visualize all layers of an image.
$ docker logs –tail 5 <container-ID/container name>  – View the logs of a container (the last 5 lines).
$ docker container top <container-ID/container name>  – Shows the process running for a container.
$ docker container stats <container-ID/container name>  – Shows live performance data of the container.


Interactions with the Docker registry

$ docker login –  Log in to the registry.
$ docker search <name>  – Search image.
$ docker pull <image name>  – Retrieve an image.
$ docker push <image>  – Push an image of the local cache to the registry.
$ docker tag <UUID> <image>: <tag>  – Tagger an image.


Docker Compose Commands

$ docker-compose up -d  – Starts a set of containers in the background.
$ docker-compose down  – Stops a set of containers.
$ docker-compose exec <service> <command>  – Execute a command within a service