Docker vs Kubernetes
Docker builds and runs containers, and Kubernetes runs containers at scale across many machines. They solve different problems, and they work together.
Build with Docker
Docker builds an image from a Dockerfile on one machine.
docker build -t greet:1.0 .Run with Docker
Docker runs that image in a container on the same machine.
docker run greet:1.0Example
docker run hello-worldKey points
- Docker: the tool that builds images and runs containers on one machine.
- Kubernetes: the tool that runs containers across many machines, and keeps them running.
- Use Docker to build an image and test it on one machine.
- Use Kubernetes when many copies must run, update and heal themselves.
- Kubernetes runs Docker images, so the two tools do not compete.
In this example, Docker runs one container on one machine. Kubernetes would only enter the picture if this app needed many copies across many machines. One machine means Docker alone is enough.
Note
A beginner needs Docker first. Kubernetes only pays off once containers already run well.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
When does Kubernetes become the right tool?