Skip to content

Docker pull fails when run from a cronjob #870

@chrisforrette

Description

@chrisforrette

Hello there, thank you for building this helper!

I'm having an issue where we've configured this ECR helper on an EC2 instance and it works fine to docker pull an image during an SSH session, but I wrote a cron job to periodically pull a specific image and it fails like so:

Sep 13 23:47:01 localhost CRON[9224]: (root) CMD (docker pull XXXXXX.dkr.ecr.us-west-1.amazonaws.com/my-image-repo:latest)
Sep 13 23:47:01 localhost dockerd[1298]: time="2024-09-13T23:47:01.737021888Z" level=info msg="Attempting next endpoint for pull after error: Get https://XXXXXX.dkr.ecr.us-west-1.amazonaws.com/v2/my-image-repo/manifests/latest: no basic auth credentials"
Sep 13 23:47:01 localhost dockerd[1298]: time="2024-09-13T23:47:01.737075289Z" level=error msg="Handler for POST /v1.40/images/create returned error: Get https://XXXXXX.dkr.ecr.us-west-1.amazonaws.com/v2/my-image-repo/manifests/latest: no basic auth credentials"

My /root/.docker/config.json looks like this:

{
	"auths": {
		"XXXXXX.dkr.ecr.us-west-1.amazonaws.com": {}
	},
	"credsStore": "ecr-login"
}

And I see nothing appending to ~/.ecr/log/ecr-login.log when these run.

My suspicion is that perhaps ~/.docker/config.json is not loaded during cron jobs but I can't find much documentation about it. Do you happen to know if this is the case? Or if there might be something else going on?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions