Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

401 Unauthorized when using AWS ECR image registry #752

Closed
AlessioFranceschi opened this issue Apr 10, 2024 · 2 comments
Closed

401 Unauthorized when using AWS ECR image registry #752

AlessioFranceschi opened this issue Apr 10, 2024 · 2 comments
Labels
triage Investigation required

Comments

@AlessioFranceschi
Copy link

Expected Behaviour
When using a third party registry using the new TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX env variable, I expect it to pull the image correctly if i'm logged in.
I'm using AWS ECR, in the terminal I can run the following commands:

aws ecr get-login-password --region <AWS_REGION> | docker login --username AWS --password-stdin <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com
docker pull image <my_image>

And it correctly pulls the image.

Actual Behaviour

  1. I set the env variable TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX to <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com
  2. I try to create a container:
const container = await new GenericContainer('myContainer:latest')
            .withPullPolicy(PullPolicy.alwaysPull())
            .start();
  1. When running, I get this error:
    Error: (HTTP code 500) server error - failed to resolve reference "<AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/myContainer:latest": unexpected status from HEAD request to <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/v2/myContainer/manifests/latest: 401 Unauthorized

Testcontainer Logs

Error: (HTTP code 500) server error - failed to resolve reference "<AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/myContainer:latest": unexpected status from HEAD request to <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/v2/myContainer/manifests/latest: 401 Unauthorized
    at /Users/user/Code/repo/node_modules/.pnpm/docker-modem@3.0.8/node_modules/docker-modem/lib/modem.js:343:17
    at IncomingMessage.<anonymous> (/Users/user/Code/repo/node_modules/.pnpm/docker-modem@3.0.8/node_modules/docker-modem/lib/modem.js:370:9)
    at IncomingMessage.emit (node:events:531:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at processTicksAndRejections (node:internal/process/task_queues:82:21)

Steps to Reproduce

  1. Set TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX to an AWS ECR url
  2. Create a container with an image from that registry

Environment Information

  • Operating System: MacOS Sonoma 14.4.1
  • Docker Version: 4.28.0
  • Node version: v21.7.1
  • Testcontainers version: 10.8.1
@cristianrgreco
Copy link
Collaborator

Fixed in #748. Will be released shortly

@cristianrgreco cristianrgreco added the triage Investigation required label Apr 10, 2024
@cristianrgreco
Copy link
Collaborator

Fixed in 10.8.2 (hopefully)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Investigation required
Projects
None yet
Development

No branches or pull requests

2 participants