Repository navigation
daemon: do not append defaults if insecure-registries are configured - #53868
Conversation
78ca29c to
1cabdd2
Compare
ac78ae3 to
824ef7c
Compare
| t.Run("defaults", func(t *testing.T) { | ||
| t.Parallel() | ||
| d := daemon.New(t) | ||
| defer d.Stop(t) | ||
| d.Start(t, "--iptables=false", "--ip6tables=false") | ||
| info := d.Info(t) | ||
|
|
||
| expectedCIDRS := []netip.Prefix{ | ||
| netip.MustParsePrefix("127.0.0.0/8"), | ||
| netip.MustParsePrefix("::1/128"), | ||
| } | ||
| assert.DeepEqual(t, info.RegistryConfig.InsecureRegistryCIDRs, expectedCIDRS, cmpopts.EquateComparable(netip.Prefix{})) | ||
| }) | ||
|
|
||
| t.Run("insecure-registries", func(t *testing.T) { | ||
| t.Parallel() | ||
| d := daemon.New(t) | ||
| defer d.Stop(t) | ||
| d.Start(t, "--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost, "--iptables=false", "--ip6tables=false") | ||
| info := d.Info(t) | ||
| d.Stop(t) | ||
|
|
||
| expectedCIDRS := []netip.Prefix{netip.MustParsePrefix(registryCIDR)} | ||
| assert.DeepEqual(t, info.RegistryConfig.InsecureRegistryCIDRs, expectedCIDRS, cmpopts.EquateComparable(netip.Prefix{})) | ||
| assert.DeepEqual(t, *info.RegistryConfig.IndexConfigs["docker.io"], registry.IndexInfo{Name: "docker.io", Mirrors: []string{}, Secure: true, Official: true}) | ||
| assert.DeepEqual(t, *info.RegistryConfig.IndexConfigs[registryHost], registry.IndexInfo{Name: registryHost, Mirrors: []string{}, Secure: false, Official: false}) | ||
| }) |
There was a problem hiding this comment.
Hmmm I think we also need a test where we test the [] empty value.
I think right now it won't work for the containerd image store because of:
Lines 28 to 37 in 824ef7c
There was a problem hiding this comment.
@vvoland I pushed a commit to make containerd's configuration align with docker (as containerd itself indeed still has an implicit default to always consider localhost insecure (but without the DNS resolution);
We should probably consider making some changes in containerd to make that more easily configurable, but I think the current approach here should work?
ffd8c48 to
c528976
Compare
c528976 to
8e9af6b
Compare
|
8e9af6b to
975ab95
Compare
Containerd implicitly allows HTTP for localhost registries based on their hostname or loopback IP address, independently of Docker's insecure registry configuration. Docker also considers DNS resolution when determining whether a registry is insecure, and may explicitly configure localhost as secure. Override containerd's implicit HTTP fallback when Docker considers the registry secure, while preserving explicit containerd host configuration. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
620926f to
264faa2
Compare
Previously, the daemon unconditionally added localhost ("::1/128", "127.0.0.0/8")
addresses as insecure registries, even if insecure registries were configured
by the user.
This patch changes the behavior to only configure the defaults if not configured.
This makes sure that only the configured addresses are set as "insecure", and
allows opting-out of the defaults by setting an empty slice in `daemon.json`
(`{"insecure-registries":[]}`).
Note that disabling insecure registries through the command-line (`--insecure-registry`)
flags is currently not possible, as these flags do not accept an empty value.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
264faa2 to
a6ecffc
Compare
|
We should also adjust docs/reference/dockerd.md section |
Ah, dang, yes it's in this repo now 😂 (might do as a follow-up?) |
* deps: engine 29.10.0 (Go 1.27.4, runc 1.5.3) and docker CLI 29.10.0 * engineconfig: keep loopback in insecure-registries for engine 29.10.0 moby/moby#53868 stops dockerd adding 127.0.0.0/8 and ::1/128 to the insecure registries once insecure-registries is set, which would cut skrog cache (http://127.0.0.1:5000) off for anyone with a corporate registry configured. Set/SetMany append them to any non-empty list, and ApplyDefaults adds them to a list that predates the upgrade. * boot-test: wait for containerd's socket, not just docker's docker.sock can come up before dockerd's managed containerd has created its socket. On 29.10.0 it did once, and the single ctr attempt failed the amd64 rootfs-v29.10.0-1 release build on a healthy engine (a re-run of the same commit passed). Retry for up to 30 s like the docker.sock wait. * release: rootfs-v29.10.0-1 and dockercli-v29.10.0 checksums (amd64, arm64)

daemon: align localhost registry handling with Docker configuration
Containerd implicitly allows HTTP for localhost registries based on their hostname or loopback IP address, independently of Docker's insecure registry configuration.
Docker also considers DNS resolution when determining whether a registry is insecure, and may explicitly configure localhost as secure.
Override containerd's implicit HTTP fallback when Docker considers the registry secure, while preserving explicit containerd host configuration.
daemon: do not append defaults if insecure-registries are configured
Previously, the daemon unconditionally added localhost ("::1/128", "127.0.0.0/8") addresses as insecure registries, even if insecure registries were configured by the user.
This patch changes the behavior to only configure the defaults if not configured. This makes sure that only the configured addresses are set as "insecure", and allows opting-out of the defaults by setting an empty slice in
daemon.json({"insecure-registries":[]}).Note that disabling insecure registries through the command-line (
--insecure-registry) flags is currently not possible, as these flags do not accept an empty value.Summary
Release notes (optional)
A picture of a cute animal (not mandatory but encouraged)