You will install Docker and run, inspect, and persist your first containers. By the end you will understand the difference between an image and a container and keep data alive with volumes.

Learning Objectives

  • Run and manage containers from public images.
  • Persist data with named volumes.
  • Inspect container networking and logs.
  • Time: ~2 hours · Difficulty: Beginner · Prereqs: a Linux host with sudo.

Architecture Overview

Environment Setup

You will need: Docker Engine 24.x (install docs).

Before you begin: add your user to the docker group or prefix commands with sudo.

Step-by-Step Execution

01
Run a container

An image becomes a container the moment you run it.

docker run -d --name web -p 8080:80 nginx:stable
Runs nginx detached, mapping host 8080 to container 80.
02
List and inspect
$ docker ps
CONTAINER ID IMAGE STATUS PORTS a1b2c3 nginx:stable Up 5 seconds 0.0.0.0:8080->80/tcp
03
Persist data with a volume

Volumes keep data when a container is removed, the key to stateful workloads.

docker volume create webdata && docker run -d --name web2 -v webdata:/usr/share/nginx/html nginx:stable
04
Read container logs
docker logs --tail 10 web

Progress So Far

Testing & Validation

curl -s -o /dev/null -w "%{http_code}\n" http://localhost:8080

You should see 200. If so, your container is serving traffic and you have completed the lab.

Troubleshooting
  • permission denied on docker.sock: add your user to the docker group and re-login.
  • port already allocated: another service uses 8080; map a different host port.
  • data lost on remove: mount a named volume rather than writing inside the container layer.

Extension Ideas

Key Results

  • Launched a working web container in under 5 minutes.
  • Persisted data across container removal with a named volume.
  • Inspected status, ports, and logs of running containers.
  • Verified the service with an HTTP 200 response.