Day 0: The Training Ground
Goal: One VM runs Docker, a replica of
itdrills.comand a browser in a container that can generate visits – everything Plausible is supposed to measure from Day 1 on. · Duration: approx. 60 min · Prerequisite: none
Briefing
- One VM
argois workstation and server at the same time. Plausible Community Edition (CE) runs there as a Docker Compose stack. - What gets measured is
itdrills.com– not the real website but a replica with four pages, a PDF and an external link. A hosts entry points the name to the VM; the real site does not get a single request. - Visits are generated by a headless Chromium in the
Playwright container. It runs the tracking script like a real browser –
curlcould not do that. - Up to Day 3 everything runs over HTTP with ports
(
:8000,:8080), from Day 4 over HTTPS behind Caddy.
VM argo 172.16.0.182
┌─────────────────────────────────────────────────────────┐
│ /etc/hosts: plausible.lab, itdrills.com ─► 127.0.0.1/::1 │
│ site (nginx) :8080 replica of itdrills.com │
│ Plausible CE (Day 1+) :8000 plausible.lab │
│ Playwright (Chromium) generates visits │
└─────────────────────────────────────────────────────────┘
Drill 1: Check the VM
# on argo
. /etc/os-release; echo "$PRETTY_NAME $(uname -m) $(nproc) vCPU"
free -h | awk '/Mem/{print $2}'
df -h / | awk 'NR==2{print $4}'
sudo ss -ltn | awk 'NR>1{print $4}' | grep -cE ':(80|443|8000|8080)$'Expected:
Ubuntu 24.04.5 LTS x86_64 4 vCPU
7.8Gi
72G
0
With ClickHouse and PostgreSQL, Plausible CE needs less than 1 GiB of
RAM when idle; the docs name at least 2 GiB. 4 GiB is enough, and with
the Playwright browser next to it things get relaxed from 6 GiB. The
four ports must be free (0).
Save your progress? Sign up for free
Drill 2: Docker from the official repo
Ubuntu’s docker.io package lags behind; the current
Compose plugin comes from Docker’s repo. The key is checked before it is
allowed to sign anything.
# on argo
sudo apt-get update -qq && sudo apt-get install -y -qq ca-certificates curl >/dev/null
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
gpg --show-keys --with-fingerprint /etc/apt/keyrings/docker.asc 2>/dev/null | sed -n 2p
C=$(. /etc/os-release && echo $VERSION_CODENAME)
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc]" \
"https://download.docker.com/linux/ubuntu $C stable" \
| sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
cut -d' ' -f4- /etc/apt/sources.list.d/docker.list
sudo apt-get update -qq
sudo apt-get install -y -qq docker-ce docker-ce-cli containerd.io \
docker-compose-plugin >/dev/null 2>&1; echo "rc=$?"
sudo usermod -aG docker ubuntuExpected:
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
https://download.docker.com/linux/ubuntu noble stable
rc=0
The fingerprint must read 9DC8 5822 … 0EBF CD88, exactly
as Docker publishes it on docs.docker.com.
Verify: The docker group only applies
in a new session – log out and back in once (exit,
reconnect via SSH), then:
# on argo
docker version --format '{{.Server.Version}}'
docker compose version
docker run --rm hello-world 2>&1 | grep -m1 HelloExpected:
29.10.0
Docker Compose version v5.8.0
Hello from Docker!
Warning: Members of the
dockergroup are effectively root (they can mount any directory of the host into a container). Fine on a lab VM, not on shared servers.
Save your progress? Sign up for free
Drill 3: Two names for the VM
Before, itdrills.com points to the real website (behind
a CDN). Afterwards it points to the VM – for IPv4 and
IPv6, so that a program that prefers IPv6 lands here too.
# on argo
getent ahosts itdrills.com | awk '{print $1}' | sort -u | head -3
printf '127.0.0.1 plausible.lab itdrills.com\n::1 plausible.lab itdrills.com\n' \
| sudo tee -a /etc/hosts
getent ahosts itdrills.com | awk '{print $1}' | sort -uExpected:
104.21.43.159
172.67.181.47
2606:4700:3031::ac43:b52f
127.0.0.1 plausible.lab itdrills.com
::1 plausible.lab itdrills.com
127.0.0.1
::1
Once a name is in /etc/hosts, glibc no longer asks DNS –
the real addresses are gone.
For the browser on your own machine, the same names belong to the VM’s address:
# on your machine, file /etc/hosts (Windows: C:\Windows\System32\drivers\etc\hosts)
172.16.0.182 plausible.lab itdrills.com
Remove this line again after the book – otherwise you cannot reach the real site.
Save your progress? Sign up for free
Drill 4: The replica of itdrills.com
Four pages, a PDF to download, a form and an external link – enough
to measure pageviews, downloads, forms and outbound links later.
</head> is on a line of its own each time; Day 3 puts
the tracking snippet in front of it.
# on argo
mkdir -p ~/plausible/site/books/sops ~/plausible/site/coming-soon \
~/plausible/site/files
cd ~/plausible/site
cat > index.html <<'EOF'
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><title>IT Drills</title>
</head>
<body>
<h1>IT Drills</h1>
<p>Hands-on courses for cloud native engineers.</p>
<ul>
<li><a href="/books/">All books</a></li>
<li><a href="/coming-soon/">Coming soon</a></li>
<li><a href="https://github.com/getsops/sops">SOPS on GitHub</a></li>
</ul>
</body></html>
EOF
cat > books/index.html <<'EOF'
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><title>Books – IT Drills</title>
</head>
<body>
<h1>Books</h1>
<ul><li><a href="/books/sops/">SOPS hands-on</a></li></ul>
</body></html>
EOF
cat > books/sops/index.html <<'EOF'
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><title>SOPS hands-on</title>
</head>
<body>
<h1>SOPS hands-on</h1>
<p><a href="/files/sops-sample.pdf">Download sample chapter (PDF)</a></p>
<form action="/books/sops/" method="get">
<input name="email" type="email" placeholder="[email protected]">
<button type="submit">Notify me</button>
</form>
</body></html>
EOF
cat > coming-soon/index.html <<'EOF'
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><title>Coming soon</title>
</head>
<body><h1>Coming soon</h1><p>Plausible Analytics hands-on</p></body></html>
EOF
printf '%%PDF-1.4\n%% Probe\n' > files/sops-sample.pdf
find . -type f | sortExpected:
./books/index.html
./books/sops/index.html
./coming-soon/index.html
./files/sops-sample.pdf
./index.html
nginx serves the pages, mounted read-only:
# on argo
docker run -d --name site --restart unless-stopped -p 8080:80 \
-v ~/plausible/site:/usr/share/nginx/html:ro nginx:1.30.7-alpine >/dev/null
sleep 2
curl -s http://itdrills.com:8080/books/sops/ | grep -o '<h1>.*</h1>'
docker image inspect nginx:1.30.7-alpine --format '{{.Architecture}}'Expected:
<h1>SOPS hands-on</h1>
amd64
nginx:1.30.7-alpine is the current stable line and
exists for amd64 and arm64.
Save your progress? Sign up for free
Drill 5: A browser in a container
The Playwright image contains Chromium with all its libraries. You
install the Node package playwright (same version as the
image) once into a folder that stays on the VM.
# on argo
mkdir -p ~/plausible/pw && cd ~/plausible/pw
cat > visit.js <<'EOF'
// Tag 0: ruft die übergebenen Adressen nacheinander auf
const { chromium } = require('playwright');
(async () => {
const b = await chromium.launch();
const p = await b.newPage();
for (const u of process.argv.slice(2)) {
const r = await p.goto(u);
console.log(r.status(), await p.title());
}
await b.close();
})();
EOF
docker run --rm --network host --user "$(id -u):$(id -g)" -e HOME=/tmp \
-v ~/plausible/pw:/pw -w /pw mcr.microsoft.com/playwright:v1.65.0-noble \
sh -c 'npm install --silent --no-audit --no-fund [email protected] &&
node visit.js http://itdrills.com:8080/ http://itdrills.com:8080/books/sops/' \
2>&1 | tail -2
ls ~/plausible/pwExpected:
200 IT Drills
200 SOPS hands-on
node_modules
package-lock.json
package.json
visit.js
The comment in visit.js says: “Day 0: visits the given
addresses one after the other”. The first run takes a good two minutes
(the image is over 1 GB). --network host lets the container
see the VM’s hosts entries and ports. --user and
HOME=/tmp make sure that node_modules belongs
to you – without them the container creates the files as root, and you
cannot delete them later. From now on this is enough:
# on argo
cd ~/plausible/pw
docker run --rm --network host --user "$(id -u):$(id -g)" -e HOME=/tmp \
-v ~/plausible/pw:/pw -w /pw mcr.microsoft.com/playwright:v1.65.0-noble \
node visit.js http://itdrills.com:8080/Expected:
200 IT Drills
Save your progress? Sign up for free
Exercise: Speed Drills
- Show which addresses
plausible.labresolves to (both protocols). Target time: 10 s - Show whether the container
siteis running and on which port. Target time: 15 s - Fetch only the title of the “Coming soon” page with
curl. Target time: 20 s
Solution
# on argo
getent ahosts plausible.lab | awk '{print $1}' | sort -u
docker ps --filter name=site --format '{{.Names}} {{.Ports}}'
curl -s http://itdrills.com:8080/coming-soon/ | grep -o '<title>.*</title>'Expected:
127.0.0.1
::1
site 0.0.0.0:8080->80/tcp, [::]:8080->80/tcp
<title>Coming soon</title>
Save your progress? Sign up for free
Checkpoint
# on argo
docker compose version --short
docker ps --format '{{.Names}}'
curl -s -o /dev/null -w '%{http_code}\n' http://itdrills.com:8080/files/sops-sample.pdf
test -d ~/plausible/pw/node_modules/playwright && echo "playwright da"Expected:
5.8.0
site
200
playwright da
playwright da means “playwright is there”.
Challenge
Prove that the replica really comes from the VM and not from the real
website – with a single curl that shows the server
header.
Hint: curl -sI shows the response
headers; the real site sits behind a CDN.
Solution
# on argo
curl -sI http://itdrills.com:8080/ | grep -i '^server'Expected:
Server: nginx/1.30.7
The real site would answer with its CDN’s header. Without the port
(:8080) and with HTTPS, the request would still go nowhere
today – that only changes with Caddy on Day 4.
Save your progress? Sign up for free
Cleanup
Nothing. Docker, the hosts entries, the container site
and ~/plausible/pw stay for all the following days.
Interview Note
- Why Docker from Docker’s repo instead of
docker.iofrom Ubuntu? Current version, current Compose plugin, security updates straight from the vendor – and the key is checked before it is trusted. - How do you test web analytics without touching the production site? Your own host name pointing to a test environment (hosts entry, both IP versions), a real browser via Playwright.
Enterprise Note
- Set up Docker hosts with configuration management (Ansible, cloud-init), pin the version and update deliberately.
- Test domains belong in a DNS zone of their own
(
staging.example.com), not in hosts files – those get forgotten. - Synthetic visits (Playwright) also work for monitoring: one run per minute, an alert when the tracking script is missing.