I needed a disposable Docker host this morning and couldn't decide between the two obvious ways to get one: DigitalOcean's "Docker on Ubuntu" 1-Click image, which already has Docker installed, or just picking a plain Ubuntu 22.04 Droplet and running apt-get install docker.io myself. I'd always assumed the 1-Click was the faster option, for the obvious reason that it skips the install step. I decided to actually time both before I reached for either one again.
I had no SSH access to the Droplets from where I was running this, so I couldn't log in and watch things happen. Instead I passed a small shell script as Droplet user data — the thing cloud-init runs on first boot — that waits for docker info to succeed, writes what it found into a JSON file, and starts a one-line Python HTTP server to serve that file on port 80. From my side, I just created the Droplet through the API, noted the timestamp, and polled the public IP until it answered. The clock that matters here is mine: the time from the API call returning to my curl getting a 200.
The plain image, three times
Three Droplets, ubuntu-22-04-x64, s-1vcpu-1gb, region fra1, nothing but apt-get update && apt-get install -y docker.io in the user data:
| Run | Public IP assigned | Docker answering a request |
|---|---|---|
| 1 | 34.5s | 129.1s |
| 2 | 33.8s | 134.0s |
| 3 | 33.5s | 165.2s |
The gap between "has an IP" and "answering" is entirely apt-get: 25 to 32 seconds of update plus install, with no lock contention in any of the three runs — I logged every retry apt-get install needed, and it got through on the first attempt every time. The run that took 165 seconds didn't spend any extra time in the installer; the difference showed up before the script even started, which I'll come back to.
The 1-Click image, three times — and nothing
I expected the Docker 1-Click image to beat that easily, since there's no package to install. I ran the same probe against three fresh docker-20-04 Droplets and got no response at all — not a late one, none, on any attempt. The first got the plain version of the script; after it timed out I rewrote the next one to also write an early "I'm booting" placeholder within seconds of the script starting, before Docker even comes into it, so I could tell a slow boot from no response at all. That didn't show up either, on either of the two Droplets that ran it. The third Droplet got the same early placeholder and tried three ports (80, 8080, 22022) instead of just one. Same result on all three ports, from an IP the API had already marked active 34 to 45 seconds in.
My first thought was that my own script was broken, so before touching anything DigitalOcean-specific I made sure the identical server-starting code worked at all — and it did, first time, on every plain-Ubuntu Droplet I tried it on. That ruled out a bug in my probe. What was left was something about the 1-Click image's own networking.
So I added two lines to the user data for a fourth Droplet: before starting anything, read and print ufw status verbose. That's all it took to find the cause:
Status: active
Default: deny (incoming), allow (outgoing), allow (routed)
To Action From
-- ------ ----
22/tcp LIMIT IN Anywhere
2375/tcp ALLOW IN Anywhere
2376/tcp ALLOW IN Anywhere
The Docker 1-Click ships with UFW turned on, set to deny all incoming traffic by default, and it opens exactly three things: rate-limited SSH, and Docker's own remote API ports, 2375 and 2376. Nothing about port 80. That's a reasonable default for a Droplet whose whole purpose is running arbitrary containers on arbitrary ports you haven't chosen yet — DigitalOcean can't guess which ports your containers will need, so it opens the ports Docker itself uses and leaves the rest to you.
To check that this really was the cause and not a coincidence, I added ufw allow 80/tcp (and 8080 and 22022, to match my other test) before starting the server, on top of just disabling UFW outright as a second attempt. Both got through. I ran the disable-UFW version three times:
| Run | Public IP assigned | Docker answering a request |
|---|---|---|
| 4 | 34.7s | 107.4s |
| 5 | 34.9s | 98.6s |
| 6 | 45.0s | 128.7s |
Once the firewall rule is out of the way, the 1-Click does come in faster on average — about 112 seconds against the plain image's 143 — but the gap is smaller than I'd expected, for a simple reason: on both images, somewhere between 95 and 132 seconds passed between my API call succeeding and the user-data script actually starting to run, well past the 34 to 45 seconds it took for the Droplet to get a public IP. A Droplet reporting "active" with a public address is a fact about the API and the network; it isn't the same moment as cloud-init starting to run whatever you handed it as user data, and that second milestone landed a lot later, and varied a lot more, than the first one on both images I tried. The handful of seconds apt-get install docker.io costs is small next to that gap, which is the real reason the two images ended up closer than I assumed.
What else differed
With both images actually answering, a few other things showed up for free. The 1-Click's Docker (29.10.0) ships with the Compose plugin built in (docker compose version returns v5.8.0 immediately). Ubuntu 22.04's own docker.io package installs Docker 29.1.3 with no docker compose subcommand at all — you'd need a separate install if you wanted Compose. And the 1-Click's base image is already using close to double the disk of the plain one before either Droplet pulls a single container: 4.2GB against 2.5GB of a 25GB disk, consistent across all three runs of each. Free memory told a similar story at idle on a 1GB Droplet — 59 to 71MB free on the 1-Click, 165 to 199MB free on the plain image. Neither is going to matter for a single small container, but it's the kind of thing I'd want to know before picking a smaller Droplet size.
What I got wrong on the way
My first script only wrote its results file right at the end, once Docker was confirmed ready, so when that Droplet went quiet I had no way to tell a slow boot from no response at all. I spent a run assuming it just needed more time and let it sit for the full six minutes before giving up. Only on the next Droplet did I add a second, much earlier version of the same file, written the instant the script starts rather than after everything else finishes — and when that didn't show up either, it was clear the problem was in front of the box, not inside it. The thing that actually found the cause was smaller than either of those: two lines at the top of the next script printing ufw status verbose before doing anything else.
Run it yourself
This is the user-data script I used for the fixed 1-Click run, trimmed of the extra ports and diagnostics I was using to track down the cause; the plain-image version just swaps the first two lines for apt-get update && apt-get install -y docker.io and drops the ufw ones. Save it as userdata.sh:
#!/bin/bash
exec > /root/setup.log 2>&1
ufw allow 80/tcp
ufw --force disable
mkdir -p /var/www/html
cd /var/www/html && setsid python3 -m http.server 80 < /dev/null &
disown
until docker info >/dev/null 2>&1; do sleep 0.5; done
{ docker --version; docker compose version; } > /var/www/html/ready.json
Create the Droplet with it as user_data (building the request body in Python avoids hand-escaping a multiline script into JSON), then poll http://<droplet-ip>/ready.json from wherever you're running this:
curl -X POST -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" -H "Content-Type: application/json" \
-d "$(python3 -c '
import json
print(json.dumps({
"name": "docker-test",
"region": "fra1",
"size": "s-1vcpu-1gb",
"image": "docker-20-04",
"user_data": open("userdata.sh").read(),
}))')" \
https://api.digitalocean.com/v2/droplets
Where I land
I'd still reach for the 1-Click image over doing it by hand, mainly for the Compose plugin being there without a second install. But I'm adding ufw allow 80/tcp 443/tcp (or whatever ports the job actually needs) to the top of every script I ever point at one, because right now the very first request I send to a fresh one goes nowhere and tells me nothing about why. And either way, I've stopped trusting "the Droplet is active" as a sign that anything I asked cloud-init to do has actually started — on both images here, that took another minute and a half on top.
Top comments (0)