One of the common question that I encounter in many discussions is – Should I use Docker or Kubernetes?
Both of them are leading technology wrt containers but comparing Docker and Kubernetes is wrong, as they are used for different reason and this blog tries to explain what are they are used for and why is it wrong to compare Docker and Kubernetes.
Docker provides services and features to package an application and its dependencies like libraries, system tools, code, and runtime in a format called container which enables it to run on any IT infrastructure.
For Example: If we have a set of APIs developed using Java spring framework, which runs on a tomcat web server then the container will contain an image of all the dependencies required to run the APIs which is application war file, tomcat web server , java etc. Once this is packaged as docker container it can be executed anywhere using Docker Engine.
Without docker or containerization, developers ship the war file and in the environment where it has to be executed, we will have to install java, then tomcat web server etc , but now with docker everything required to run the API is in the container itself.
One of key attributes of Docker is its portability. Docker containers can run across any desktop, data center, or cloud environment.
The generated container images can be shared through a container registry like Docker Hub or Azure Container Registry.
Containers also helps to run applications consistently across a large number of machines and software environments, because everything required to run the application is packaged in the container. Therefore it eliminates many of the conflicts that comes from differences in tools and software between teams and environments.
This makes them particularly well-suited for DevOps, easing the way for developers and IT operations to work together across environments and solves one of the main problem -“It works on my machine “
As the number of container applications grow , managing and operating them becomes very complex like how do you scale the containers, how do we do load balancing , service discovery, scheduled deployment, scaling, rollback , health checkup , configuration management etc.
This is where Kubernetes or k8s help. It eliminates many of the manual process required to manage containers at scale. you can cluster together groups of hosts running containers, and Kubernetes helps you easily and efficiently manage those clusters.
It provides services to users that allows to orchestrate and run containers effectively from keeping long-running services ‘always on’ to more efficiently managing intensive shorter-term tasks like builds
It is what helps IT make the potential of containers an operational reality.
Some of the features of K8 are
- Deployment: Schedules and automates deployment of containers to specified hosts and keeps containers running in a desired state.
- Service discovery and load balancing: Exposes a container on the internet and employs load balancing when traffic spikes occur to maintain stability.
- Self-healing capabilities: Restarts, replaces, or reschedules containers when they fail or when nodes die, and kills containers that don’t respond to user-defined health checks.
- Automated rollouts and rollbacks: Rolls out application changes and monitors application health for any issues, rolling back changes if something goes wrong.
- Storage orchestration: Automatically mounts a persistent local or cloud storage system of choice as needed.
Kubernetes and Docker work together and are highly complementary and make a powerful combination.
Kubernetes is a popular and leading container orchestration system but some of the other alternatives are – Docker Swarm, Nomad, Apache Mesos
Thank you and share your comments / feedback .