Write Dockerfiles and Build Custom Images
Author a single-stage Dockerfile from scratch, build a tagged image for a static site, and observe layer caching in action.

Lab overview
A Dockerfile is a plain-text recipe that tells Docker how to assemble a container image, instruction by instruction. Each line (FROM, COPY, RUN, and CMD) becomes a stacked, content-addressed layer, and Docker's build engine BuildKit reuses any layer whose inputs have not changed since the last build. This is what makes container builds reproducible across machines and dramatically faster on repeat runs.
Writing Dockerfiles by hand is the foundational skill that everything else in the container ecosystem (compose stacks, Kubernetes manifests, CI/CD pipelines, registry workflows) sits on top of. Sloppy ordering produces 800 MB images that take three minutes to push; careful ordering produces 25 MB images that rebuild in seconds. This lab uses a small static website as the canvas to give you a working mental model for how BuildKit assembles, caches, and invalidates layers - so that the Dockerfiles you write next, for your own applications, are fast, small, and predictable from the start.
Objectives
Upon completion of this beginner level lab, you will be able to:
- Author a Dockerfile and build a tagged custom image using FROM, WORKDIR, COPY, EXPOSE, and CMD.
- Run the built image as a container and verify it serves the expected content over HTTP.
- Inspect image layers with
docker image historyand observe how edits invalidate the BuildKit cache. - Use a
.dockerignorefile to control what enters the build context.
Who is this lab for?
This lab is designed for:
- Engineers and students taking their first hands-on steps with Docker
- DevOps practitioners who want to write smaller, faster, more cache-friendly images for their CI/CD pipelines
Verified against your live environment
An automated validation engine inspects your actual resources and configurations as you work. Completion means the task was performed — not multiple choice, real-world proficiency.
More labs like this
Docker Container Networking - Bridges, Custom Networks, and DNS
Master Docker networking with the default bridge, user-defined bridges, embedded DNS, and network isolation.
Introduction to Azure Bicep - Write and Deploy Your First Template
Learn Azure Bicep syntax by writing your first template to deploy a storage account with parameters, variables, and outputs using Azure CLI.
Terraform Providers - Configure, Version, and Lock Dependencies
Configure the AWS Terraform provider with version constraints, explore the dependency lock file, and upgrade provider versions safely.
Environment
Every lab includes
- Real environment, pre-credentialed
- Automated checks on every step
- Isolated sandbox, auto cleanup
- AI-recommended next steps
Lab curriculum
- 01
Getting Started with Docker IDE
- 02
Author Your First Dockerfile for a Static Site
1 automated check
- 03
Observe Layer Caching and Add a Dockerignore File
1 automated check
- 04
Run and Verify the Custom Image Serves Content
1 automated check
Skills validated
Not the lab you were looking for?
Browse 150+ hands-on labs across AWS, Azure, Kubernetes, Docker, and cloud security.