Skip to content

Commit bc44cb8

Browse files
authored
fix registry auth (#4146)
Signed-off-by: Avi Deitcher <avi@deitcher.net>
1 parent 33ee279 commit bc44cb8

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

src/cmd/linuxkit/pkg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ func pkgCmd() *cobra.Command {
101101
cmd.PersistentFlags().BoolVar(&dirty, "force-dirty", false, "Force the pkg(s) to be considered dirty")
102102
cmd.PersistentFlags().BoolVar(&devMode, "dev", false, "Force org and hash to $USER and \"dev\" respectively")
103103

104-
cmd.PersistentFlags().StringSliceVar(&registryCreds, "registry-creds", nil, "Registry auths to use for building images, format is <registry>=<username>:<password> OR <registry>=<registry-token>. If no username is provided, it is treated as a registry token. <registry> must be a URL, e.g. 'https://index.docker.io/'. May be provided as many times as desired. Will override anything in your default.")
104+
cmd.PersistentFlags().StringSliceVar(&registryCreds, "registry-creds", nil, "Registry auths to use for building images, format is <registry>=<username>:<password> OR <registry>=<registry-token-base64>; do NOT forget to base64 encode it. If no username is provided, it is treated as a registry token. <registry> must be a URL, e.g. 'https://index.docker.io/'. May be provided as many times as desired. Will override anything in your default.")
105105
return cmd
106106
}

src/cmd/linuxkit/pkglib/docker.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,13 @@ func (dr *dockerRunnerImpl) build(ctx context.Context, tag, pkg, dockerContext,
593593
cf = configfile.New("custom")
594594
// merge imageBuildOpts.RegistryAuths into dockercfg
595595
for registry, auth := range imageBuildOpts.RegistryAuths {
596-
bareRegistry := strings.TrimPrefix(registry, "https://")
597-
bareRegistry = strings.TrimPrefix(bareRegistry, "http://")
598-
cf.AuthConfigs[bareRegistry] = dockerconfigtypes.AuthConfig{
599-
ServerAddress: bareRegistry,
596+
// special case for docker.io
597+
registryWithoutScheme := strings.TrimPrefix(registry, "https://")
598+
registryWithoutScheme = strings.TrimPrefix(registryWithoutScheme, "http://")
599+
if registryWithoutScheme == "docker.io" || registryWithoutScheme == "index.docker.io" || registryWithoutScheme == "registry-1.docker.io" {
600+
registry = "https://index.docker.io/v1/"
601+
}
602+
cf.AuthConfigs[registry] = dockerconfigtypes.AuthConfig{
600603
Username: auth.Username,
601604
Password: auth.Password,
602605
RegistryToken: auth.RegistryToken,

0 commit comments

Comments
 (0)