Introduction
When it comes to container technology Docker and Kubernetes are the two leading open source tools. And while they are fundamentally different technologies that assist users with container management, they are complementary to one another and can be powerful when combined. So let's discuss the technology that binds them together. Containers ?
What are Containers?
If you plan to deploy your application to the cloud or other production environment, you will need your application to run in a different environment from your development machine. Unfortunately, you might not have direct control over the cloud environment or the software installed, and this could cause problems for your application. This issue can be fixed with a container or virtual machine that bundles an application with its dependencies and environment. A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another.
Benefits of Containers
- Containers make it easy for developers to create, build and deploy applications into different environments and platforms.
- Containers share a single kernel and share application libraries.
- Containers are lightweight compared to Virtual Machines.
Several container engines/runtime allows us to create containers. Some are :
- Docker - A standardized packaging format for diverse applications
- CRI-O - Lightweight container runtime for Kubernetes
- OpenVZ - Open source container-based virtualization for Linux
- Containerd - Container runtime with an emphasis on simplicity, robustness, and portability
- Rkt - An application container engine developed for modern production cloud-native environments
- LXC and LXD - A distro and vendor-neutral environment for the development of Linux container technologies
What is Docker?
Docker is an open-source tool for containerization. It helps to build, test and run containers.
Let's understand a few terms before we dive deeper:
- Docker Engine
Docker Engine is an application that consists of a daemon, an API, and a client
The Docker daemon is a server that manages the images, containers, networks, and volumes.
- The Docker client is the user interface for Docker. The client is a CLI, so most of the work you do with Docker will take place at the command line.
The client communicates with the daemon through the command line API as shown in the image below.
- Docker Image
A Docker image is the set of instructions for creating a container. The image typically includes a file system and the parameters that will be used for the container.
You can create a custom Docker image for a specific application. Start with a standardized parent image as the base layer. The parent image often contains the file system of a particular operating system, such as Ubuntu 18.04. Then add an additional layer to the image, on top of the base layer. You can add your application files to this additional layer. You can even add multiple additional layers, and distribute your application files across different layers, as appropriate for your needs.
- Docker Container
You have already been introduced to containers, and a Docker container is just the Docker-specific implementation of the concept. In practice, Docker containers are created from Docker images - a container is a runnable instance of an image. Note that since the image is a set of instructions for creating a container, multiple containers can be created from the same image.
- Dockerfile
A simple text file that defines everything needed to build a Docker container image, such as OS network specifications and file locations. It’s essentially a list of commands that Docker Engine will run to assemble the image.
- Docker Compose
A tool for defining and running multi-container applications. It creates a YAML file to specify which services are included in the application and can deploy and run containers with a single command via the Docker CLI.
Resources to read furthermore
IBM Cloud - https://www.ibm.com/cloud/blog/kubernetes-vs-docker