What are Docker and Kubernetes? What are they used for?

From a distance, Docker and Kubernetes can appear to be similar technologies; they both help you run applications within Linux containers. If you look a little closer, you’ll find that the technologies operate at different layers of the stack, and can even be used together.

Containers are a way of packaging software. What makes them unique is that when you run a container, you know exactly how it will run - it’s predictable, repeatable, and immutable. There are no unexpected errors when you move it to a new machine, or between environments. All of your application’s code, libraries, and dependencies are packed together in the container as an immutable artifact. You can think of running a container like a virtual machine, without the overhead of spinning up an entire operating system. For this reason, bundling your application in a container vs. a virtual machine will improve startup time significantly.

Docker helps you create and deploy software within containers. It’s an open-source collection of tools that help you “Build, Ship, and Run Any App, Anywhere”.

With Docker, you create a special file called a Dockerfile. Dockerfiles define a build process, which, when fed to the ‘docker build’ command, will produce an immutable docker image. You can think of this as a snapshot of your application, ready to be brought to life at any time. When you want to start it up, just use the ‘docker run’ command to run it anywhere the docker daemon is supported and running. It can be on your laptop, your production server in the cloud, or a raspberry pi. Regardless of where your image is running, it will behave the same way.

Kubernetes is an open-source container orchestration platform, that allows large numbers of containers to work together in harmony, reducing operational burden. It helps with things like:

  • Running containers across many different machines
  • Scaling up or down by adding or removing containers when demand changes
  • Keeping storage consistent with multiple instances of an application
  • Distributing load between the containers
  • Launching new containers on different machines if something fails.

Kubernetes isn’t the only container management tool around. Docker also has its own native container management tool called Docker Swarm. It lets you deploy containers as Swarms that you can interact with as a single unit, with all the container management taken care of. To be clear, Kubernetes does not interact with Docker Swarm in any fashion, only the Docker engine itself.

Comments