Kubernetes vs Docker
Kubernetes vs Docker is a comparison between two tools with different jobs. Docker builds and runs containers. Kubernetes runs containers across many machines.
Docker runs one container
One command starts one container on your machine. Docker handles that machine only.
docker run -d --name web nginx:1.27Kubernetes runs many copies
One command asks for three copies. Kubernetes spreads them across the cluster.
kubectl get podsDocker stops at one machine
Docker sees your machine. It does not see the other machines in a cluster.
docker psKubernetes sees the whole cluster
Kubernetes sees every machine. It picks the machine with room for each container.
kubectl get nodesExample
docker run -d --name web nginx:1.27
kubectl get podsKey points
- Docker: a tool that builds container images and runs containers on one machine.
- Kubernetes: a system that runs containers across a group of machines.
- Image: a frozen file that holds an app and everything it needs to run.
- Registry: a store that holds container images.
- Use Docker to build an image and test it on your own machine.
- Use Kubernetes to run that image on many machines at once.
In this example, the first command uses Docker to start one container on this machine. The second command asks Kubernetes to list the running containers. Docker handles one machine. Kubernetes handles the whole group.
Note
The two tools work together. Kubernetes is not a replacement for Docker.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
Which tool builds a container image and runs it on one machine?