From image to replica
Containers and Kubernetes
An image is a filesystem plus a start command. A container is a process wearing that filesystem. Kubernetes adds the part a single machine cannot give you: scheduling, a stable address, and reconciliation to a declared number of replicas.
Image, container, process
A Dockerfile is a recipe; building it produces an image — a layered filesystem plus metadata such as the default command and the port the app listens on. Running the image starts a process in its own namespaces, which is what a container is.
Because the kernel is shared, containers start in milliseconds where a VM boots a whole operating system. The trade-off is the boundary: a container is isolated by kernel features, not by virtual hardware.
Pods, Services, Deployments
Kubernetes schedules Pods, not containers: a Pod is one or more containers that share a network address. Pods are disposable, so their IPs are too.
A Service gives you one stable name and port by selecting Pods with labels. A Deployment declares how many replicas should exist and replaces the ones that die — which is why you almost never create a bare Pod in production.
What usually goes wrong
Most first failures are a mismatch, not a crash: the Service selects a label no Pod carries, so it has no endpoints. The next most common is a stale image — the source changed, but the container is still running yesterday's build.
Configuration that lives in a ConfigMap does not reach running Pods until they restart. 'I updated the config and nothing changed' is that, nine times in ten.
Commands in this lesson
Every one of these runs in the sandbox — no real account, no real bill.
| Command | Why |
|---|---|
docker build -t web-app:1.0 . | Tag the artefact, do not rely on `latest`. The `.` is the build context. |
docker run -d --name web-app -p 3000:3000 web-app:1.0 | Detached, named, and publishing host 3000 to container 3000. |
kubectl apply -f web-pod.yaml | Declare the object; the cluster reconciles to it. |
kubectl apply -f web-deploy.yaml | Same idea one level up: replicas and a selector instead of a single Pod. |
kubectl get pods | The first question after any apply: did it schedule, and is it ready? |
Now do it
Reading the model makes the first attempt faster. Only the lab makes you able to do it.
- Open the lab
Dockerize a Web Application
Beginner · 30 min · members
- Open the lab
Run a Pod Behind a Service
Beginner · 30 min · members
- Open the lab
Scale a Deployment and Configure It
Intermediate · 35 min · members
Containers and Kubernetes · OphirCloud Academy · all lessons