testcontainers-java: Cannot pull images when logged in to Docker Desktop (Status 500: unauthorized: incorrect username or password)
Test Containers 1.16.3 on Docker Engine 20.10.12 with Docker Desktop using WSL2 Backend on Windows 21H1.
When I am logged in to my account in Docker Desktop, Test Containers can no longer pull images from Docker Hub. Once I log out of my account, Test Containers is able to pull images as expected.
com.github.dockerjava.api.async.ResultCallbackTemplate - Error during callback
com.github.dockerjava.api.exception.InternalServerErrorException: Status 500: {"message":"Head \"https://registry-1.docker.io/v2/testcontainers/ryuk/manifests/0.3.3\": unauthorized: incorrect username or password"}
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:247)
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
at java.base/java.lang.Thread.run(Thread.java:833)
I think my Docker installation is fine, as I can pull images from the terminal when I am logged in to Docker Desktop. I don’t want to log out every time I use Test Containers. How can I fix this issue?
Logs (on INFO): https://pastebin.com/fyExxi76
Logs (on DEBUG): https://pastebin.com/b4H283fL
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 32 (12 by maintainers)
Commits related to this issue
- 109 integration tests using docker fail with mac m1 arm (#114) - Fix testcontainers for integration tests - startDockerContainer takes http endpoint for up check - Exclude jna from spring-shell as ... — committed to spring-projects-experimental/spring-boot-migrator by fabapp2 2 years ago
- Added Docker portion from integration testing Note: If it isn't working, make sure to log out of docker. See: https://github.com/testcontainers/testcontainers-java/issues/5121 — committed to erik-lance/enlistment-enterprise by erik-lance a year ago
- Fixed the issue breaking the tests: namely the older version of testcontainers/dockerDesktop v.4.22.0 that forces mitigations as advised in the issue (https://github.com/testcontainers/testcontainers-... — committed to beezerbt/spring-time-in-kotlin-episode5 by beezerbt 10 months ago
Based on the idea behind the PR I tried the following workaround with the current release and it works for me on Windows:
Would anyone affected like to give it a try as well?
That worked for me on M1 Macbook Pro. It added an
{"auths":{"index.docker.io":{}}}entry in my~/.docker/config.jsonfile. Thereafter the workaround persists across, restarts, etc.The fix that worked for me on an M1 Mac was: remove
credsStore:desktopfrom~/.docker/config.json, rundocker loginin terminalProblem still exists with Test Containers 1.16.3 and Docker Desktop with versions: 4.2.0, 4.3.2, 4.6.1 and 4.7.0 Actually, it happens regardless if I’m logged in or not.
Image pulled manually via
docker pull testcontainers/ryuk:0.3.3works just fine. It’s just a workaround though.@dermoritz So you say, login with exactly
docker login index.docker.iodid not help?I’m running Docker Desktop 4.7.0 (77141) on Windows 21H2. As a new user, I was completely unable to find any workaround from the selection above. I tried logging out, logging in via the UI, logging in via the command line, logging into
registry.hub.docker.com, nothing worked.I then went to Docker Desktop and clicked “Reset to factory defaults” and it worked perfectly first time (not logged in). I tried deleting the images and it re-download them perfectly.
However, when I then logged in using the command line and removed the images, it failed again. Once I reset Docker Desktop again, everything worked again.
Hope that helps.
This worked for me running the test from the Micronaut Data-JDBC guide. I used the following dependencies from jitpack:
Thanks a lot for sharing your experiences @jodastephen, this really helps in triaging this issue. I am currently in the process of debugging and triaging as well.
What seems to help is to, in addition to performing a
docker logout, also remove the Docker config file:I currently suspect this is caused by changes to the Docker Hub registry, but the permutation in which this is currently failing are unfortunately not 100% clear to me yet.
@SiwyDym I see. Can you instead confirm that it works if your Docker daemon is unautheticated? (after
docker logout)I cannot confirm that, the only working mitigation for me is manually pulling the image
testcontainers/ryuk:0.3.3@StFS Can you please ask about this in Slack, or open a dedicated discussion/issue? This issue is about Docker Desktop.
@kiview I just tried the command line fix on macOS 12.3.1 (M1 Pro) running Docker Desktop 4.8.1 and confirmed it works here too.
Thank you!
Edit: This was also using Testcontainers 1.16.2
I am also having this exact issue. I am setting up a new development environment on a M1 Max MacBook Pro, with latest Docker (darwin/arm64). I have tried all the suggestions in the previous comments; i.e. logging out of docker, logging in via CLI (with and without
registry.hub.docker.com), reset Docker to factory defaults, delete.docker/config.json.The only thing that ever works for me is to manually pull the image
testcontainers/ryuk:0.3.3Docker Desktop 4.7.0 (77141) Docker version 20.10.14, build a224086 macOS 12.3.1 (21E258)
Another interesting aspect to try out is if doing a
docker login registry.hub.docker.commitigates the situation.I can confirm that issue occurs when I login by Docker Desktop GUI 😐 Docker Desktop:
4.7.0 (77141)OS:12.1 (21C52)@awojcik64 How I perceive the error so far with regards to pulling public images with Testcontainers:
docker login): working ✅For further triangulation, may I ask you @SiwyDym if you are sure that on macOS, you recently did a login through the Docker Desktop GUI and it still worked? Also, please make sure the images are not cache before trying out Testcontainers.
So as a current workaround, I’d suggest doing the
docker loginfrom CLI instead of the GUI and everything should work fine.I have exactly the same issue with Test Container 1.16.2. This issue only occurs if the Docker image has to be pulled. As long as I have a local image everything is fine.