Skip to content

Lab · DevOps: Git, Docker, Kubernetes and CI/CD

Lab: containerise a kirana shop's price API

Labbeginner· about 2 hours· 5 steps

The brief

Sharma Kirana wants its price list on a small web API that runs the same on any machine. You write a Dockerfile that builds a non-root image, run it with a port mapping, keep its data in a named volume across container restarts, and push it to a local registry.

Why it matters

Packaging an app as an image is the first thing a DevOps engineer does for any service: the same image then runs on a laptop, in CI, on a VM and on Kubernetes. Interviewers routinely ask you to write a Dockerfile, explain -p and -v, and say why containers should not run as root.

Skills you practise

  • Dockerfile: FROM, WORKDIR, COPY, RUN, USER, EXPOSE, CMD
  • docker build and image inspect
  • docker run -d -p -e -v
  • named volumes
  • tags and a local registry

You need

  • Docker Desktop (Windows or macOS) or Docker Engine on Linux, version 24 or newer
  • A bash-style terminal: on Windows use Git Bash or WSL (in PowerShell, type curl.exe instead of curl)

What you will have at the end

A kirana-api folder with a pinned, non-root Dockerfile and .dockerignore, and the commands that run it with a port, an environment variable and a named volume, and push it to a registry.

How it is marked (rubric, 100 points)
Checks passAll five outputs pass: the engine, the image settings, the port mapping, the persistent volume and the pushed tag.45
Dockerfile qualityPinned slim base, a non-root USER, exec-form CMD, and a .dockerignore that keeps .git and .env out.25
Understands the run flagsYou can say what -d, -p HOST:CONTAINER, -e and -v NAME:PATH each do.15
Tidy workContainers and test volumes removed at the end, and commands written down in order.15

0/5 steps done

Step 1 of 5

Check that Docker works

The Docker engine answers with its version and runs the hello-world container.

Docker has two parts: the docker command (the client) and the engine (the daemon) that builds and runs containers. docker version --format asks the engine for its version, so it fails if the engine is not running. hello-world is a tiny official image that prints a message and exits; --rm removes the stopped container afterwards.

Run this on your machine, then paste the output below
$ docker version --format '{{.Server.Version}}'; docker run --rm hello-world
Your notes: Dockerfile, .dockerignore

Write down each command you ran. It goes into your project summary.