Skip to content

Commit

Permalink
Merge pull request moby#48540 from thaJeztah/insecure_ipv6_localhost
Browse files Browse the repository at this point in the history
daemon: add IPv6 loopback as insecure registry
  • Loading branch information
thaJeztah authored Sep 23, 2024
2 parents 3cf65ec + 6a1d8a9 commit c7e42d8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6005,7 +6005,7 @@ definitions:
accept un-encrypted (HTTP) and/or untrusted (HTTPS with certificates
from unknown CAs) communication.
By default, local registries (`127.0.0.0/8`) are configured as
By default, local registries (`::1/128` and `127.0.0.0/8`) are configured as
insecure. All other registries are secure. Communicating with an
insecure registry is not possible if the daemon assumes that registry
is secure.
Expand Down
3 changes: 3 additions & 0 deletions daemon/reload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func TestDaemonReloadAllowNondistributableArtifacts(t *testing.T) {
}

registries := []string{
"::1/128",
"127.0.0.0/8",
"10.10.1.11:5000",
"10.10.1.33:5000", // This will be added during reload.
Expand Down Expand Up @@ -225,6 +226,7 @@ func TestDaemonReloadInsecureRegistries(t *testing.T) {
// initialize daemon with existing insecure registries: "127.0.0.0/8", "10.10.1.11:5000", "10.10.1.22:5000"
daemon.registryService, err = registry.NewService(registry.ServiceOptions{
InsecureRegistries: []string{
"::1/128",
"127.0.0.0/8",
"10.10.1.11:5000",
"10.10.1.22:5000", // this will be removed when reloading
Expand All @@ -237,6 +239,7 @@ func TestDaemonReloadInsecureRegistries(t *testing.T) {
}

insecureRegistries := []string{
"::1/128", // this will be kept
"127.0.0.0/8", // this will be kept
"10.10.1.11:5000", // this will be kept
"10.10.1.33:5000", // this will be newly added
Expand Down
4 changes: 3 additions & 1 deletion integration/system/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,14 @@ func TestInfoInsecureRegistries(t *testing.T) {
defer d.Stop(t)

info := d.Info(t)
assert.Assert(t, is.Len(info.RegistryConfig.InsecureRegistryCIDRs, 2))
assert.Assert(t, is.Len(info.RegistryConfig.InsecureRegistryCIDRs, 3))
cidrs := []string{
info.RegistryConfig.InsecureRegistryCIDRs[0].String(),
info.RegistryConfig.InsecureRegistryCIDRs[1].String(),
info.RegistryConfig.InsecureRegistryCIDRs[2].String(),
}
assert.Assert(t, is.Contains(cidrs, registryCIDR))
assert.Assert(t, is.Contains(cidrs, "::1/128"))
assert.Assert(t, is.Contains(cidrs, "127.0.0.0/8"))
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})
Expand Down
2 changes: 1 addition & 1 deletion registry/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (config *serviceConfig) loadMirrors(mirrors []string) error {
func (config *serviceConfig) loadInsecureRegistries(registries []string) error {
// Localhost is by default considered as an insecure registry. This is a
// stop-gap for people who are running a private registry on localhost.
registries = append(registries, "127.0.0.0/8")
registries = append(registries, "::1/128", "127.0.0.0/8")

var (
insecureRegistryCIDRs = make([]*registry.NetIPNet, 0)
Expand Down

0 comments on commit c7e42d8

Please sign in to comment.