Docker From Zero: Host a Website and Seven Other Fun Things in Containers
On this page
Most of this blog is security, but I’ve been a builder far longer than I’ve been a defender — and on every side project, the tool I reach for first is Docker. Not because containers are trendy, but because Docker quietly killed the four most annoying words in software: “works on my machine.”
This is the gentle, fun version of Docker. No Kubernetes, no microservices architecture diagrams. Just the mental model, a website running in about 30 seconds, and a pile of genuinely entertaining things you can spin up on a rainy afternoon.
The whole idea, in one picture
Forget the jargon for a second. Docker lets you put an application and everything it needs to run — the right language version, libraries, config, all of it — into a single sealed box. That box runs identically on your laptop, your friend’s laptop, or a $5 server, because the box is the environment.
Three words are all you need:
If cooking helps: the Dockerfile is the recipe, the image is the frozen ready-meal, and the container is the dish actually cooking on your stove. The registry (Docker Hub) is the shop where you grab ready-made meals instead of cooking from scratch.
Install it and prove it works
Grab Docker Desktop (macOS/Windows) or Docker Engine (Linux) from docker.com, then confirm it’s alive:
docker run hello-world
That one command pulls a tiny image from the registry, runs it in a container, prints a friendly message, and exits. You just ran your first container. That’s the whole loop.
Project 1 — host a website in 30 seconds
Here’s the moment Docker clicks for most people. Want a real web server? Don’t install anything:
docker run -d -p 8080:80 nginx
Open http://localhost:8080 and there’s a running Nginx web server. -d runs it in the background, and -p 8080:80 wires your laptop’s port 8080 to port 80 inside the container.
Now make it your site — mount a folder of your own HTML into it:
# put an index.html in the current folder, then:
docker run -d -p 8080:80 -v "$PWD":/usr/share/nginx/html nginx
Refresh, and you’re looking at your own page. When you want it reproducible — the thing you can hand to anyone or deploy to a server — write a tiny Dockerfile:
# Dockerfile
FROM nginx:alpine
COPY . /usr/share/nginx/html
docker build -t my-site . # bake the image
docker run -d -p 8080:80 my-site # run it anywhere, forever
That image now contains your whole site and its web server. It runs the same on your machine and on a $5 VPS. That’s the magic in one example.
Two containers that talk: Compose
Real apps are usually more than one piece — a site and a database. Docker Compose describes the whole set in one file so docker compose up starts everything together:
# docker-compose.yml
services:
web:
build: .
ports: ["8080:80"]
db:
image: postgres:16
environment:
POSTGRES_PASSWORD: devsecret
volumes: ["dbdata:/var/lib/postgresql/data"]
volumes:
dbdata:
docker compose up -d # both containers, one command
docker compose down # stop and clean up
One file, your whole stack. Commit it next to your code and anyone can run your project in seconds.
Eight genuinely fun things to build
This is where it gets addictive. Once you realise your laptop can run anything in a throwaway box, the ideas don’t stop.
- Host your own website or portfolio. Exactly what we just did — then push the image to a cheap server and it’s live.
- A throwaway database. Need Postgres for ten minutes to test something?
docker run -d -e POSTGRES_PASSWORD=dev -p 5432:5432 postgres. When you’re done,docker rm -fit — your laptop stays clean, no leftover install. - Your own little cloud (self-hosting). This is the gateway drug. Run privacy-friendly versions of apps you’d normally rent: a password manager (Vaultwarden), a notes app, a read-later service, a network-wide ad blocker (Pi-hole), a personal dashboard. One
docker compose upeach, and you’ve built a homelab. - A disposable sandbox. Open a suspicious document or poke at a sketchy link inside a container you throw away afterwards — the mess stays in the box, not on your machine. (This is the on-ramp to the serious version in my malware-analysis lab posts.)
- Try any Linux tool without installing it. Want to test a command-line tool once?
docker run --rm -it ubuntu bashdrops you into a clean Linux shell that vanishes on exit.--rmmeans “delete the container when it stops.” - A clean dev environment per project. Project A needs Node 18, Project B needs Node 22? Give each its own container and never fight a version conflict again.
- A game server or a bot. A Minecraft server for friends, or a Discord bot that just runs — containers make “leave it running” trivial, and tearing it down is one command.
- Run an AI model locally. Pair this with my local agentic-AI guide:
docker run -d -p 11434:11434 ollama/ollamagives you a private LLM server in a box — no API key, nothing leaves your machine.
Keep it tidy (so it doesn’t eat your disk)
Two habits save you from Docker’s one real annoyance — silently filling your disk:
docker ps # what's running right now
docker ps -a # everything, including stopped containers
docker system prune # reclaim space: remove stopped containers, unused images
And one concept worth knowing early: volumes. A container’s own filesystem is disposable — delete the container and its data is gone. If you want data to survive (a database, your notes app), store it in a volume (the -v dbdata:/path bits above). Disposable by default, persistent on purpose.
A little caution: containers are isolated, not magic. Only run images from sources you trust (official images on Docker Hub are a safe start), don’t paste
docker runcommands you don’t understand that mount your whole disk, and remember that-pexposes a port on your network. For the serious flip side — what containers mean when you’re the one investigating a breach — see my DFIR considerations for Docker.
The cheat sheet I keep nearby
Ninety percent of day-to-day Docker is a dozen commands. Here’s the set worth pinning above your desk.
Running & managing containers
docker run -d -p 8080:80 nginx # run detached, map host:container ports
docker run --rm -it ubuntu bash # interactive shell, auto-delete on exit
docker ps # containers running now
docker ps -a # all containers, including stopped
docker stop <name|id> # graceful stop
docker start <name|id> # start a stopped one
docker rm <name|id> # remove a container (add -f to force)
docker restart <name|id> # stop + start
Images
docker images # images on disk
docker pull postgres:16 # fetch an image from the registry
docker build -t my-site . # build an image from a Dockerfile
docker tag my-site user/my-site:1.0 # name it for pushing
docker push user/my-site:1.0 # publish to a registry
docker rmi <image> # delete an image
Look inside & debug (the ones that save you)
docker logs -f <name> # follow a container's output (live tail)
docker exec -it <name> bash # open a shell inside a running container
docker inspect <name> # full JSON: IPs, mounts, env, ports
docker stats # live CPU/memory per container
docker cp <name>:/path ./local # copy files out of (or into) a container
Compose (multi-container projects)
docker compose up -d # start the whole stack in the background
docker compose ps # what's running in this project
docker compose logs -f web # follow one service's logs
docker compose exec web sh # shell into a service
docker compose down # stop & remove (add -v to drop volumes)
Reclaim disk (run these when things feel bloated)
docker system df # how much space Docker is using
docker system prune # remove stopped containers + unused data
docker system prune -a --volumes # aggressive: also unused images & volumes
Two shortcuts I use constantly:
docker logs -f <name>the moment something misbehaves (the answer is almost always in there), anddocker exec -it <name> bashto poke around inside a container as if you’d SSH’d in — no SSH required.
Where this leaves you
Docker’s whole promise is that the gap between “it runs on my laptop” and “it runs on a server for the world” collapses into one image you can hand to anyone. Start with the website — docker run -d -p 8080:80 nginx — then pick one idea from the list and give yourself a weekend. The best way to learn Docker isn’t a course; it’s self-hosting something you actually want to use.
Worth reading next: the Docker docs’ getting-started guide, Awesome-Selfhosted for a rabbit-hole of apps to run, and — when you’re ready for the security angle — my DFIR considerations for Docker containers.