Docker 101

What is Docker?

Docker is an open-source containerization platform. It enables developers to package applications into containers which are standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment.

Containers are made possible by the process isolation and virtualization capabilities built into the Linux kernel. These capabilities (such as control groups (Cgroups) for allocating resources among processes, and namespaces for restricting a processes access, or visibility, into other resources or areas of the system) enable multiple application components to share the resources of a single instance of the host operating system in much the same way that a hypervisor enables multiple virtual machines (VMs) to share the CPU, memory, and other resources of a single hardware server.

As a result, container technology offers all the functionality and benefits of VMs (including application isolation, cost-effective scalability, and disposability) plus important additional advantages:

  • Lighter weight: Unlike VMs, containers don’t carry the payload of an entire OS instance and hypervisor. They include only the OS processes and dependencies necessary to execute the code. Container sizes are measured in megabytes (vs. gigabytes for some VMs), make better use of hardware capacity, and have faster startup times.

  • Greater resource efficiency: With containers, you can run several times as many copies of an application on the same hardware as you can using VMs. This can reduce your cloud spending.

  • Improved developer productivity: Compared to VMs, containers are faster and easier to deploy, provision, and restart. This makes them ideal for use in continuous integration and continuous delivery (CI/CD) pipelines, and a better fit for development teams adopting Agile and DevOps practices.

../../_images/docker_vs_vms.png

For further information please visit https://docs.docker.com/get-started/overview/

Principal Docker Components and Tools

Docker Components

  • Software: The Docker daemon, called dockerd, is a persistent process that manages Docker containers and handles container objects. The daemon listens for requests sent via the Docker Engine API. The Docker client program, called docker, provides a command-line interface (CLI), that allows users to interact with Docker daemons.

  • Objects: Docker objects are various entities used to assemble an application in Docker. The main classes of Docker objects are images, containers, and services.
    • A Docker container is a standardized, encapsulated environment that runs applications. A container is managed using the Docker API or CLI.

    • A Docker image is a read-only template used to build containers. Images are used to store and ship applications.

    • A Docker service allows containers to be scaled across multiple Docker daemons. The result is known as a swarm (a set of cooperating daemons that communicate through the Docker API).

  • Registries: A Docker registry is a repository for Docker images. Docker clients connect to registries to download (“pull”) images for use or upload (“push”) images that they have built. Registries can be public or private. Two of the main public registries are Docker Hub and Docker Cloud. Docker Hub is the default registry where Docker looks for images. Docker registries also allow the creation of notifications based on events.

Docker Tools

  • Docker Compose is a tool for defining and running multi-container Docker applications. It uses YAML files to configure the application’s services and performs the creation and start-up process of all the containers with a single command. The docker-compose CLI utility allows users to run commands on multiple containers at once (for example, building images, scaling containers, running containers that were stopped, and more). Commands related to image manipulation, or user-interactive options, are not relevant in Docker Compose because they address one container. The docker-compose.yml file is used to define an application’s services and includes various configuration options. For example, the build option defines configuration options such as the Dockerfile path (the command option that allows one to override default Docker commands and more).

  • Swarm provides native clustering functionality for Docker containers, which turns a group of Docker engines into a single virtual Docker engine. In Docker 1.12 and higher, Swarm mode is integrated with Docker Engine. The docker swarm CLI utility allows users to run Swarm containers, create discovery tokens, list nodes in the cluster, and more. The docker node CLI utility allows users to run various commands to manage nodes in a swarm (for example, listing the nodes in a swarm, updating nodes, and removing nodes from the swarm). Docker manages swarms using the Raft consensus algorithm. According to Raft, for an update to be performed, the majority of Swarm nodes need to agree on the update.

  • Volumes facilitate the independent persistence of data, allowing data to remain even after the container is deleted or re-created.

../../_images/docker_taxonomy.png

References