Skip to content

Unable to use docker credentials for ACR #1224

@ikstewa

Description

@ikstewa

Expected Behavior

When attempting to pull a base image from a private ACR we should be able to leverage the credentials from docker desktop.

Current Behavior

Pulling the base image fails with error:

> Could not build image: failed to resolve reference "myacr.azurecr.io/myimage:mytag": failed to authorize: failed to fetch oauth token: unexpected status from GET request to https://myacr.azurecr.io/oauth2/token?scope=repository%3Amyimage%3Apull&service=myacr.azurecr.io: 401 Unauthorized

Steps to Reproduce (for bugs)

  • az acr login -n myacr
  • ./gradlew buildImage
val buildImage = tasks.register<DockerBuildImage>("buildImage") {
    dependsOn(dockerSyncBuildContext)
    images.addAll(
      "myacr.azurecr.io/mynewimage:" + project.version,
      "myacr.azurecr.io/mynewimage:latest")
}

Docker config file ~/.docker/config.json:

{
	"auths": {
		"ghcr.io": {},
		"myacr.azurecr.io": {}
	},
	"credsStore": "desktop",
	"currentContext": "default",
	"plugins": {
		"-x-cli-hints": {
			"enabled": "true"
		},
		"debug": {
			"hooks": "exec"
		},
		"scout": {
			"hooks": "pull,buildx build"
		}
	},
	"features": {
		"hooks": "true"
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions