Ask all your coding questions @ codequery.io

What is Docker?

Docker is a platform for running containers. Containers are lightweight isolated environments for running your applications with shared resources.

Using Docker, you can easily create and deploy applications across different environments. This is because containers don't rely on their own operating system and can instead run on a shared host's kernal with other containers.

Docker works by leveraging namespaces and cgroups on a host machine to create isolation between containers. This is what allows containers to utilize the same underlying resources while preserving their own file systems.

Still confused? Check out What is Docker? and A Quick Explanation of Docker for more on how Docker works.

What is Kubernetes?

Kubernetes represents decades of work done by Google to run apps at scale. Kubernetes is a platform for orchestrating containers with Docker (or Docker alternatives).

Using Kubernetes, you define a desired state for your system. Kubernetes then continuously executes to achieve this desired state. If containers go down, Kubernetes can bring up new containers and make adjustments to achieve the desired state.

Kubernetes manages load balancing, secret configuration, and resource allocation based on configurations you provide. This makes it easy to scale containers across a distributed system.

Basics of Docker and Kubernetes

Kubernetes manages a given number of containers running on a given number of physical machines (nodes). Each node in a Kubernetes cluster is able to start/stop containers through its container runtime interface (CRI).

Docker is the most popular implementation of this CRI. Using Docker (or another CRI), each node can coordinate with a centralized API server (Kubernetes) for managing the collective system.

Kubernetes provides the framework for this collective system or "cluster" of machines. A master controller communicates with worker nodes through a centralized API server. These worker nodes run containers in isolated groups called "pods" and use the Kubernetes API server to report the health and status of these pods back to the master controller. This is how Kubernetes continuously works to achieve a desired state for the system.

What is the Difference Between Kubernetes and Docker?

Kubernetes is an orchestration system for running containers. Docker is software that allows you to communicate with those containers on a given node.

Kubernetes relies on a CRI to start/stop containers on a given node. Docker is an implementation of that CRI.

Do you need Docker for Kubernetes?

No. Kubernetes supports several container runtimes including Docker, containerD, cri-o, rktlet, and any implementation under Kubernetes CRI (container runtime interface).

A CRI gives worker nodes a way to stop/start containers. Kubernetes integrates with many of these in addition to Docker.

Kubernetes without Docker

You can run Kubernetes with any supported CRI.

Which is better? Kubernetes vs Docker (Swarm)

Docker Swarm provides clustering for Docker. Using Swarm, you can manage a similar relationship between worker nodes and master nodes to that of Kubernetes.

Like Kubernetes, Docker Swarm also handles load balancing and scalability. While it lacks in internal tools for logging and monitoring, it can be used as an alternative to Kubernetes.