IT 3300 : Virtualization

Docker — Basics

Docker components

  • Docker Engine — the daemon that builds and runs containers
  • Client (docker) — the CLI you type commands into
  • Registry — where images are stored and shared
    (Docker Hub, GHCR, private registries)

Install Docker

  • On a Proxmox VM in your public VLAN:

      sudo apt update && sudo apt install -y curl
      curl -sSL https://get.docker.com/ | sh
      sudo usermod -aG docker $USER
    
  • Log out/in (or reboot), then verify docker works without sudo

Image vs. container

  • Image — a read-only package: code + runtime + libs + config
  • Container — a running instance of an image (image + state)
  • One image, many containers

Your first container

    docker run hello-world
  • docker — the client
  • run — create and start a container
  • hello-world — the image to use
  • Not found locally? Docker pulls it from the registry, then runs it

Running something useful

    docker run -d -p 8080:80 --name web nginx
  • -d — detached (background)
  • -p 8080:80 — map host 8080 to container 80
  • --name web — a friendly name
  • Visit http://<vm-ip>:8080

Everyday commands

  • docker ps — running containers (-a for all)
  • docker images — local images
  • docker logs web — a container's output
  • docker exec -it web bash — a shell inside it
  • docker stop web / docker rm web — stop / remove

Images from the registry

  • docker pull ubuntu:22.04 — download an image
  • Tags name versions: nginx:1.27, nginx:latest
  • latest is just a default tag, not "newest guaranteed" — pin real
    versions in production

The container lifecycle

docker run   -> created + started
docker stop  -> stopped (state kept)
docker start -> running again
docker rm    -> gone (writable layer deleted)

Data in the writable layer dies with the container — hence volumes (next).

Cleaning up

  • docker rm <name> — remove a container
  • docker rmi <image> — remove an image
  • docker system prune — reclaim space from unused stuff (careful)

Lab goals

  • Run nginx and reach it from your browser
  • Exec into it and edit the served page
  • Remove the container, re-run it, and observe your edit is gone