DEV Community

Alex Georgiev
Alex Georgiev

Posted on AI-assisted

Why my local Docker registry broke the day I upgraded

I keep a throwaway registry container on port 5000 for pushing test images while I work on other things, and after I upgraded Docker Engine this week a routine push to it just stopped working. Nothing about my setup had changed. The error was blunt:

failed to do request: Head "https://127.0.0.1:5000/v2/dp-alpine/blobs/sha256:bf8527eb...":
http: server gave HTTP response to HTTPS client
Enter fullscreen mode Exit fullscreen mode

That's the error you get when Docker decides a registry isn't trusted for plain HTTP any more. I hadn't touched my daemon config. So I went and read what actually changed in 29.10, then spent the rest of the afternoon reproducing it properly rather than just trusting the changelog.

What actually changed

Docker Engine has always had a quiet default: anything on 127.0.0.0/8 or ::1/128 gets treated as an insecure registry automatically, so a local-only push or pull over plain HTTP just works without any configuration. Docker 29.10.0, released on 16 November, narrows that default. Here's the line from the release notes that explains it:

If you explicitly configure insecure-registries in daemon.json or use --insecure-registry, Docker Engine no longer automatically treats loopback addresses as insecure registries.

The "if" matters. I checked both sides of it on the actual engine, not just the text.

With no daemon.json at all:

$ docker info --format '{{.RegistryConfig.InsecureRegistryCIDRs}}'
[127.0.0.0/8 ::1/128]
Enter fullscreen mode Exit fullscreen mode

Loopback is still trusted by default. Nothing in the common case breaks. Then I added a daemon config for a made-up private registry, the kind of thing a lot of people already have for a company mirror:

{ "insecure-registries": ["myregistry.example.com:5000"] }
Enter fullscreen mode Exit fullscreen mode

Same command, after a restart:

$ docker info --format '{{.RegistryConfig.InsecureRegistryCIDRs}}'
[]
Enter fullscreen mode Exit fullscreen mode

Loopback dropped out of the list the moment I configured myregistry.example.com:5000. I didn't ask it to. Now my own registry on 127.0.0.1 is, as far as the daemon's concerned, a TLS endpoint with no certificate behind it, so push, pull and login all hit the same wall:

$ docker login 127.0.0.1:5000 -u x -p x
Error response from daemon: Get "https://127.0.0.1:5000/v2/": http: server gave HTTP response to HTTPS client

$ docker pull 127.0.0.1:5000/dp-alpine:test
Error response from daemon: failed to resolve reference "127.0.0.1:5000/dp-alpine:test":
failed to do request: Head "https://127.0.0.1:5000/v2/dp-alpine/manifests/test":
http: server gave HTTP response to HTTPS client
Enter fullscreen mode Exit fullscreen mode

None of those took long to fail. 37, 45, 42, 38 and 38 milliseconds across five tries, so it wasn't a race against the registry container still booting. If you're hunting a CI timeout somewhere else in the pipeline, it won't be here — the daemon refuses before the request leaves the box.

localhost:5000 fails identically, because it resolves to the same loopback address. That part I expected. What I didn't expect was how different the two documented fixes turned out to be once I actually tried them.

The combination that triggers this isn't exotic. Anyone running a self-hosted mirror — Harbor, Nexus, a plain registry:2 container behind a reverse proxy without a public CA cert — already has an insecure-registries entry for it. If the same machine is also where you build and push test images locally, which is exactly what a laptop or a CI runner does, you have both halves of the combination without ever deciding to.

The two fixes aren't the same fix

The release notes suggest adding the loopback ranges back explicitly. I tried the obvious version first — widening the config to a CIDR:

{ "insecure-registries": ["myregistry.example.com:5000", "127.0.0.0/8"] }
Enter fullscreen mode Exit fullscreen mode
config push to 127.0.0.1:5000 push to 127.0.0.1:5001
no insecure-registries succeeds succeeds
["myregistry.example.com:5000"] fails fails
["myregistry.example.com:5000", "127.0.0.0/8"] succeeds succeeds
["myregistry.example.com:5000", "127.0.0.1:5000"] succeeds fails

That last row is the one I'd have got wrong if I'd stopped at the first working test. Adding the exact 127.0.0.1:5000 entry — which is what I'd naturally reach for if I only cared about the one registry port I use — fixes that port and nothing else. I spun up a second registry container on 5001 to check, and it failed with the exact same HTTPS error as before. If you run a different registry port per branch, per test run, or per CI job, as plenty of setups do, you need the CIDR, not the specific address. The specific address looks more precise and does less.

It's narrower than it sounds

The part of this that had me worried for about five minutes, before I tested it, was CI. A lot of pipelines spin up a registry as a sibling container and push to it over the Docker network rather than over 127.0.0.1. I tagged an image for my second registry's bridge address instead of its published port:

$ docker push 172.17.0.3:5000/dp-alpine:test
failed to do request: Head "https://172.17.0.3:5000/v2/dp-alpine/blobs/sha256:...":
http: server gave HTTP response to HTTPS client
Enter fullscreen mode Exit fullscreen mode

Same failure — but that's not new in 29.10. A container's bridge address was never inside the automatic loopback range, on any version. If your pipeline already names that address in insecure-registries (it has to, or it never worked at all), 29.10 changes nothing for it. The actual blast radius is specifically people who push straight to 127.0.0.1 or localhost for local testing, and who also already have an unrelated insecure-registries entry for something else. That's a real combination, but it's narrower than "Docker broke local registries."

What the proper fix costs, measured against the quick one

Both documented options are workarounds. The actual fix is a certificate the client trusts, so I built one and timed it rather than assuming it was expensive:

$ time openssl req -newkey rsa:2048 -nodes -keyout registry.key -x509 -days 2 \
    -out registry.crt -subj "/CN=127.0.0.1" -addext "subjectAltName=IP:127.0.0.1"
real    0m0.34s
Enter fullscreen mode Exit fullscreen mode

Add the cert to the registry container, drop the same certificate into /etc/docker/certs.d/127.0.0.1:5000/ca.crt, and the whole thing — key, cert, registry restart, Docker trust directory — took 2.7 seconds end to end on my machine, then pushed cleanly over real TLS in 0.14 seconds.

The detail that surprised me: I never restarted the Docker daemon for that. Dropping a certificate into certs.d takes effect immediately. Every insecure-registries edit, by contrast, needed a full daemon restart to pick up, and my test registry container didn't come back on its own afterwards — I had to docker start it again each time, because this engine runs with Live Restore off by default. A one-line JSON edit sounds like the cheap option. In practice, it's the one that takes your containers down for a moment; the certificate is the one that doesn't.

What I got wrong on the way

I wanted the cleanest possible comparison: the old engine and 29.10 against the identical daemon.json, side by side, so "it worked before" wasn't just something the release notes told me. I downloaded the 29.9.1 static binary meaning to run it as a second daemon on a separate socket and data root. I couldn't get a second daemon running cleanly alongside the first in my environment, and rather than force it, I dropped that comparison. Everything about the new behaviour above — the dropped CIDR, the failing push, both fixes, the bridge-address test, the certificate timing — is something I ran and watched fail or succeed on the actual 29.10 engine. The claim that loopback registries worked unconditionally before 29.10 is Docker's own release note, not a result I reproduced on the old binary myself, and I'd rather say that plainly than blur the two.

Run it yourself

docker run -d --name test-registry -p 5000:5000 registry:2
docker pull alpine:3.20 && docker tag alpine:3.20 127.0.0.1:5000/alpine:test

echo '{ "insecure-registries": ["myregistry.example.com:5000"] }' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
docker push 127.0.0.1:5000/alpine:test     # fails on 29.10

echo '{ "insecure-registries": ["myregistry.example.com:5000", "127.0.0.0/8"] }' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker
docker push 127.0.0.1:5000/alpine:test     # works again
Enter fullscreen mode Exit fullscreen mode

Where I landed

If you already have any insecure-registries entry and you also push to 127.0.0.1 locally, check this before you upgrade, not after a CI job mysteriously starts failing. Concretely:

  • Use the 127.0.0.0/8 CIDR, never a specific host:port, unless you genuinely only ever use one local port.
  • Don't treat this as a reason to avoid 29.10. The default case — no insecure-registries at all — is completely unaffected, and I'd guess that's most people reading this.
  • If a local registry is going to live longer than an afternoon, give it a real certificate. It cost me under three seconds to set up and didn't need a daemon restart, which the JSON-edit workaround did.

Top comments (2)

Collapse
 
mickyarun profile image
arun rajkumar •

The row in your table I would put at the top is the third against the fourth. ["myregistry.example.com:5000", "127.0.0.0/8"] works for both ports, and ["myregistry.example.com:5000", "127.0.0.1:5000"] works for one. Someone who hit this, fixed it narrowly and moved on now has a config that is correct today and breaks the first time they bring up a second registry on another port. The narrow fix turns a loud failure into a quiet one, which is a worse position than the upgrade left them in.

The general shape is the part worth naming. Before 29.10 the loopback trust was a default, and a default is not in your config file, so it cannot be reviewed. Configuring insecure-registries for an unrelated host replaced that policy rather than adding to it. Nothing in daemon.json mentioned loopback before or after, so there was no line to read and no diff to catch.

The rule I would take from it, and it generalises well past Docker: when a default is load-bearing, write it down even when it is still the default. 127.0.0.0/8 belonged in that list before anything forced it there, not because the behaviour needed changing but because the file should state the policy it relies on. Config that depends on absence is config you cannot review.

Your caveat about the default case being unaffected is the right one and I would keep it prominent. The people who hit this are the ones who had already configured one insecure registry, which is a smaller group than the headline sounds.

Collapse
 
alexgeorgiev17 profile image
Alex Georgiev •

agreed, and "config that depends on absence is config you cannot review" is a better summary than anything in the post. if you're writing it down anyway, put ::1/128 in next to 127.0.0.0/8, that was the other half of the old default, and localhost can resolve to ::1 on some setups.

the closest thing to a diff I found is the effective value rather than the file. docker info --format '{{.RegistryConfig.InsecureRegistryCIDRs}}' printed [127.0.0.0/8 ::1/128] with no daemon.json and [] as soon as I added the other registry. saving that before and after an upgrade would have caught this one.