Docker Basics

Learn through engaging narratives and interactive challenges

6 lessons available

Lessons

1

The Wizard's Container Spell

Docker is a tool that packages applications into containers โ€” lightweight, portable environments that run the same everywhere. The key mental model: Dockerfile (recipe) โ†’ Image (template) โ†’ Container (running instance). Think of it like Java: .java file โ†’ .class file โ†’ running in JVM.

2

Summoning Your First Creature

The 'docker run' command creates and starts a container from an image. If the image isn't available locally, Docker automatically downloads it from Docker Hub (a public registry of images). 'docker ps' shows running containers. Real-world use: spin up a web server, database, or any tool in seconds โ€” no installation required.

3

Writing Your First Spell Scroll

A Dockerfile is a text file with instructions to build a Docker image. Key instructions: FROM (base image to start from), RUN (execute commands during build), CMD (default command when container starts). Every Dockerfile must start with FROM. Real-world use: package your Java app so anyone can run it identically โ€” no JDK installation needed on the target machine.

4

The Art of Layered Enchantment

In lesson 02 we wrote FROM, RUN, CMD โ€” but how does your code get INTO the image? That's COPY. And where does it go? That's WORKDIR. Finally, EXPOSE documents which port your app listens on. Imagine you have a Java app (App.java) with a simple HTTP server on port 8080 โ€” you need to COPY it in, compile it with RUN, and EXPOSE the port. Each instruction creates a cached layer โ€” Docker only rebuilds what changed. Real-world use: package any Java app so anyone can run it without installing a JDK.

5

Treasure Chests and Tower Windows

Containers are ephemeral โ€” when they stop, their data is gone. Volumes (-v) persist data outside the container. Port mapping (-p) connects container ports to your machine: '-p 8080:80' means 'my port 8080 โ†’ container port 80'. Real-world use: run a DB2 database with persistent storage, or expose your Java web app to the browser.

6

Assembling Your Party of Creatures

Docker Compose lets you define and run multi-container applications in a single YAML file. Instead of running multiple 'docker run' commands, you describe all services in docker-compose.yml and start everything with 'docker compose up'. Services can communicate by name. Real-world use: a Java web app with a DB2 database โ€” all defined in one file, started with one command.

Your Progress

0 of 6 lessons completed