diff --git a/daemon/config/config.go b/daemon/config/config.go index 66a0c76db8..c2d464f8c3 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -748,6 +748,12 @@ func Validate(config *Config) error { } } + for _, mirror := range config.ServiceOptions.Mirrors { + if _, err := registry.ValidateMirror(mirror); err != nil { + return err + } + } + if config.CorsHeaders != "" { // TODO(thaJeztah): option is used to produce error when used; remove in next release return errors.New(`DEPRECATED: The "api-cors-header" config parameter and the dockerd "--api-cors-header" option have been removed; use a reverse proxy if you need CORS headers`) diff --git a/daemon/config/config_test.go b/daemon/config/config_test.go index bf89f672c3..20514404a0 100644 --- a/daemon/config/config_test.go +++ b/daemon/config/config_test.go @@ -14,6 +14,7 @@ import ( "github.com/docker/docker/api" "github.com/docker/docker/libnetwork/ipamutils" "github.com/docker/docker/opts" + "github.com/docker/docker/registry" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" "github.com/spf13/pflag" @@ -428,6 +429,17 @@ func TestValidateConfigurationErrors(t *testing.T) { platform: "windows", expectedErr: "invalid exec-opt (native.cgroupdriver=systemd): option 'native.cgroupdriver' is only supported on linux", }, + { + name: "invalid mirror", + config: &Config{ + CommonConfig: CommonConfig{ + ServiceOptions: registry.ServiceOptions{ + Mirrors: []string{"ftp://example.com"}, + }, + }, + }, + expectedErr: `invalid mirror: unsupported scheme "ftp" in "ftp://example.com": must use either 'https://' or 'http://'`, + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) {