question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker images are pulled by anonymous user rather then authenticated

See original GitHub issue

I have logged in with docker login -u <username> and base64 encrypted record was written to ~/.docker/config.json as:

"https://index.docker.io/v1/": {
	"auth": "<base64encoded username:password>"
}

However, when I use Testcontainers it pulls images as an anonymous user rather than authenticated. Examined by pull ratelimit-remaining check:

[anonymous] TOKEN=$(curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
[authenticated] TOKEN=$(curl --user 'username:password' "https://auth.docker.io/token?service=registry.docker.io&scope=repository:ratelimitpreview/test:pull" | jq -r .token)
curl --head -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest

I see that anonymous user pull ratelimit-remaining decreases, however for an authenticated user, it stays the same.

The problem leads to reaching Docker pull rate limit much faster

Error during callback: com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"toomanyrequests: You have reached your pull rate limit

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
rnorthcommented, Jan 17, 2022

I think you’ve run into this existing issue: https://github.com/testcontainers/testcontainers-java/issues/4474

The key log lines are:

09:50:45.727 [build-33] INFO  🐳 [docker.io/postgres:14.1] - Pulling docker image: docker.io/postgres:14.1. Please be patient; this may take some time but only needs to be done once.
09:50:45.728 [build-33] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: docker.io/postgres:latest at registry: docker.io
09:50:45.728 [build-33] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator has configFile: /home/kshpak/.docker/config.json (exists) and commandPathPrefix: 
09:50:45.728 [build-33] DEBUG org.testcontainers.utility.RegistryAuthLocator - registryName [docker.io] for dockerImageName [docker.io/postgres:latest]
09:50:45.728 [build-33] DEBUG org.testcontainers.utility.RegistryAuthLocator - No matching Auth Configs - falling back to defaultAuthConfig [null]

If you were to remove the docker.io/ prefix from your image name, I think it should work…

1reaction
rnorthcommented, Jan 12, 2022

@kshpak I notice that you’ve edited your comment above, presumably due to credentials appearing.

I’ve deleted the original revision of the comment so that it cannot be retrieved.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Resource Consumption Updates FAQ - Docker
Unauthenticated pull requests are “anonymous” and will be rate limited based on IP address rather than user ID. For more information on authenticating...
Read more >
How can I pull anonymously but require authentication ... - JFrog
User -added image. Thereafter, you will be able to pull images anonymously, as is demonstrated in the following example: & docker pull ......
Read more >
Authenticating with Docker Hub for AWS Container Services
In this post, you will learn how to authenticate with Docker Hub to pull images from private repositories using both Amazon ECS and...
Read more >
Nexus Docker Registry - Failling anonymous pull
While it works with authenticated users, trying to use anonymous user to pull images doesn't work. This happens only on a docker client....
Read more >
Caching Docker images to reduce the number of calls ... - GitLab
For pull requests by anonymous users, this limit is now 100 pull requests ... will then use your mirror instead of connecting to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found