#WithRegistryAuth Failing

1 messages · Page 1 of 1 (latest)

summer mountain
#

Hey All,

Have the following func:

func pushImage(ctx context.Context, base []*dagger.Container, props BuildProps, sourceUserName string, sourcePassword *dagger.Secret) (string, error) {

    platformVariants := make([]*dagger.Container, 0, len(base))
    for _, container := range base {
        var dir = container.Directory("/src/sample-app/target/")
        var files, _ = dir.Glob(ctx, "**/*.jar")
        var perms = dagger.ContainerWithFileOpts{
            Owner: "1000:0",
        }

        var platform, platformErr = container.Platform(ctx)
        if platformErr != nil {
            log.Fatal(platformErr)
        }
        var repo = strings.Split(props.AppContainer, "/")[0]
        // select output directory
        var prodImage = dag.Container(dagger.ContainerOpts{Platform: platform}).
            WithRegistryAuth(repo, sourceUserName, sourcePassword).
            From(fmt.Sprintf("%s:%s", props.AppContainer, props.AppVersion))

But for the life of me cant get it to work:

[2025-08-20T05:03:16.482Z] 44  : ┆ ┆ resolving xx.docker.io.xxx.com/server-core:4.50.3 ERROR [0.6s]
[2025-08-20T05:03:16.482Z] 44  : ┆ ┆ ! failed to authorize: failed to fetch anonymous token: unexpected status from GET request to https://xx.docker.io.xx.com:443/artifactory/api/docker/xx/v2/token?scope=repository%3Aserver-core%3Apull&service=xx.docker.io.xx.com%3A443: 401
#

Tried using env:// and file://. Daggers called using the following:

dagger call build --srcCodeDir=/home/jenkins/workspace/kube --mavenSettings=/home/jenkins/.m2/..data/settings.xml --sourceDockerUserName=xx-jenkins --sourceDockerPassword=file://xx.docker.io.xx.com.txt --destinationDockerUserName=AWS --destinationDockerPassword=file://xxx.dkr.ecr.us-west-2.amazonaws.com.txt --tag=b4eeb0095071a4fd1db7f46c49fbe402ee0abb85 --dockerAgentUserName=AWS --dockerAgentPassword=file://xxx.dkr.ecr.us-west-2.amazonaws.com.txt

I've double checked the files and they contain the tokens/secrets. The AWS portion works, seemingly just not the part that auths against artifactory. Anyone else had this issue?

uneven patio
summer mountain
#

I've tried using PAT tokens and username/pass.

#

If i could set break points I might be able to inspect vars n stuff.

#

Will keep plugging away.

uneven patio
#

reason I'm asking is beceause if you do a docker login with the corresponding credentials, Dagger will use that automatically and WithRegistryAuth should not be necessary

#

maybe that's an option that works for you

summer mountain
#

CI

#

works fine locally

#

its in Kube that Im having issues 🙁

uneven patio
#

or you have to use docker login?

summer mountain
#

have to use docker login.

#

using legacy (for lack of a better word) docker repos in artifactory

#

have a plan to test using oci repos to see if that works.

uneven patio