-
-
Notifications
You must be signed in to change notification settings - Fork 252
Description
Expected Behaviour
When pulling images during build, use dockerhub credentials from ~/.docker/config.json to avoid image pull rate limits.
Actual Behaviour
testcontainer correctly reads correctly the config made with docker login but it does not use them correctly when pulling images from the DockerImageClient.indexServerAddress, which in my case should be "https://index.docker.io/v1/" . The image that is pulled as a base for a dockerfile (for e.g. node) resolves to localhost registry and therefore GenericContainerBuilder.getRegistryConfig appears to try to resolve auth config for localhost, even though it should resolve auth for "https://index.docker.io/v1/".
Testcontainer Logs
2026-02-17T14:42:52.562Z testcontainers [DEBUG] Auth config cache hit for registry "https://index.docker.io/v1/"
2026-02-17T14:42:52.562Z testcontainers [DEBUG] No auth config found for registry "localhost"
...
2026-02-17T14:42:52.825Z testcontainers:build [localhost/b791bf657a34:342e57541ebf] {"stream":"Step 1/10 : FROM postgres:17.7"}
--
2026-02-17T14:42:52.825Z testcontainers:build [localhost/b791bf657a34:342e57541ebf] {"stream":"\n"}
2026-02-17T14:42:53.916Z testcontainers:build [localhost/b791bf657a34:342e57541ebf] {"status":"Pulling from library/postgres","id":"17.7"}
2026-02-17T14:42:54.218Z testcontainers:build [localhost/b791bf657a34:342e57541ebf] {"errorDetail":{"message":"toomanyrequests: You have reached your unauthenticated pull rate limit. https://www.docker.com/increase-rate-limit"},"error":"toomanyrequests: You have reached your unauthenticated pull rate limit. https://www.docker.com/increase-rate-limit"}
Steps to Reproduce
- npm i testcontainers@11.11.0
- Place a Dockerfile into a directory and create container with
const DOCKER_CONTEXT = 'your_directory'
const image = await GenericContainer.fromDockerfile(DOCKER_CONTEXT).build();
- before running the project perform
docker loginso ~/.docker/config.json has auth data - Spam until rate limit for unauthenticated user is hit. (it should not be, since you are authenticated)
Environment Information
- Operating System: ubuntu:20.04 (aws/codebuild/standard:5.0 CI machine)
- Docker Version: 20.10.24
- Node version: 22.22.0
- Testcontainers version: 11.11.0
Are you willing to try to solve this?
Yes.