DevOps Engineer · Step 5 of 8 · 10 min
Containers and Kubernetes basics
Build and run a container, and explain what Kubernetes adds on top.
What a container is
A container packages an app with everything it needs to run: libraries, runtime and settings. It runs the same on your laptop, in CI and in production. That ends the old excuse: it works on my machine.
Containers share the host's operating system kernel, so they start in seconds and are much lighter than virtual machines. An image is the packaged template; a container is a running copy of it.
Docker and friends
Docker made containers popular. You write a Dockerfile listing the steps to build an image, then docker build and docker run. Images follow an open standard from the Open Container Initiative, so other tools such as Podman can build and run them too.
Docker Desktop is free for personal use, education and small businesses, but larger companies need a paid subscription. Check your employer's licence. Keep images small, and never bake secrets into them.
What Kubernetes does
Running one container is easy. Running hundreds across many machines, restarting them when they crash and rolling out new versions without downtime is not. Kubernetes is the most common system for this, called container orchestration.
You describe what you want in YAML: run three copies of this image, expose them on this port. Kubernetes keeps reality matching that description. The key words are pod, the smallest unit; deployment, which manages copies and updates; service, a stable address; and the control plane that runs it all.
Do you need it?
Kubernetes is powerful and complex. Many small teams do well with simpler managed options that run containers for them. Learn the concepts because employers ask, but do not assume every project needs a cluster.
Try it
Run your first container for free
- 1.Install Docker Desktop or Podman, or use a free browser sandbox such as Play with Docker.
- 2.Run docker run hello-world and read what it printed.
- 3.Ask a chatbot for a Dockerfile for a tiny web app in a language you know, build it and run it.
- 4.For Kubernetes, try a free Killercoda scenario or install kind or minikube locally. Nothing here needs a cloud account.
Explain this Dockerfile line by line, and suggest two changes that would make the image smaller and safer: [paste Dockerfile].