分享

Kubernetes? Docker? What is the difference?

 imnobody2001 2018-09-20

dockervskubernetes

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. 

Understanding both Docker and Kubernetes is essential if you want to build and run a modern cloud infrastructure. Let’s take a look to see how they both fit into the world of linux containers, and how you can use them when architecting your own applications.

Containers - A Quick Intro

At their core, containers are a way of packaging software. What makes them special 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 running 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.

The above characteristics make containers an awesome tool and essential building block in modern cloud architecture. While the industry pushes towards building microservice architectures, containers help facilitate quick elasticity and separation of concerns. And while some may not yet be building microservices, traditional monoliths can be containerized and reap some of the aforementioned benefits.

This all sounds really nice, but how do you actually build a container?

Build and Deploy Containers with Docker

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”. Yes, it really is as magic as it sounds. 

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 on a raspberry pi. Regardless of where your image is running, it will behave the same way. 

Docker also provides a cloud-based repository called Docker Hub. You can think of it like GitHub for Docker Images. You can use Docker Hub to store and distribute the container images you build.

Manage Containers with Kubernetes

Once you’ve recovered from the excitement of spinning up your first few Docker containers, you’ll realize that something is missing. If you want to run multiple containers across multiple machines - which you’ll need to do if you’re using microservices - there is still a lot of work left to do.

You need to start the right containers at the right time, figure out how they can talk to each other, handle storage considerations, and deal with failed containers or hardware. Doing all of this manually would be a nightmare. Luckily, that’s where Kubernetes comes in.

Kubernetes is an open source container orchestration platform, allowing 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 

Wait, Doesn’t Docker do Container Management?

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.

New call-to-action

Using Docker with Kubernetes

As previously mentioned, Docker and Kubernetes work at different levels. Under the hood, Kubernetes can integrate with the Docker engine to coordinate the scheduling and execution of Docker containers on Kubelets. The Docker engine itself is responsible for running the actual container image built by running ‘docker build’. Higher level concepts such as service-discovery, loadbalancing and network policies are handled by Kubernetes as well.

When used together, both Docker and Kubernetes are great tools for developing a modern cloud architecture, but they are fundamentally different at their core. It is important to understand the high-level differences between the technologies when building your stack.

Let Containership help unravel the mysteries of cloud computing for you. Regardless of where you are in your cloud journey, we can help. 

LEARN MORE

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多