testcontainers / testcontainers-java

Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
https://testcontainers.org
MIT License
8k stars 1.65k forks source link

No explicit documentation for .docker/config.json usage for registry auth #1419

Closed athlordJojo closed 5 years ago

athlordJojo commented 5 years ago

If this is a duplicate: i'am sorry, but i couldn't find any help in the docs...

I have the following setup: Jenkins runs a gradle-task inside docker (so i use docker.sock). From the gradle-job, i start my Integration test using testcontainers. My problem starts, when i want to use private repositories from jffrog (public images works fine). I tried to set the environment variables to the docker command which runs the gradle command via:

-e \"registryUsername=foo\" -e \"registryPassword=bar\" -e \"registryUrl=https://companyname.jfrog.io\"

Inside the container which runs gradle, i can see that the values are set correctily. But none of the values are picked up from testcontainers, which results in an error, complining about not be able to load the images...

What am i missing ? I found this change log but no docs how to configure it...

Any help is welcome, thank you!

athlordJojo commented 5 years ago

Ok, i found a solution: Create this file ~/.docker/config.json via the following command in the jenkins, before the tests are started via gradle:

sh 'echo "{\\"auths\\":{\\"https://company-docker.jfrog.io\\":{\\"auth\\": \\"\$(echo -n \$JFROG_USR:\$JFROG_PWD | base64)\\"}}}" > ~/.docker/config.json'

I really think, that this should be documented in testcontainers, even if it's part of docker-java.

kiview commented 5 years ago

Hi @athlordJojo, thanks for the remarks and providing the solution with an example. Do you think we should duplicate this into our docs, or just add references to docker-java?

athlordJojo commented 5 years ago

Hey @kiview !

I really think, that this should be part of testcontaines documentation. For example: I didn't even knew, that textcontainers uses docker-java, so i didn't looked at there documentation.

kiview commented 5 years ago

Yes, this definitely makes sense. But we could just link to https://github.com/docker-java/docker-java#properties-docker-javaproperties for example.

By the way, the $HOME/.docker/config.json is a general Docker approach, not docker-java specific I just realized: https://docs.docker.com/engine/reference/commandline/login/

athlordJojo commented 5 years ago

ok, so will add the documentation ? becasue then we could close this issue.

rnorth commented 5 years ago

I'd agree that this needs to be in the documentation. If anyone would like to raise a PR to add, it would be appreciated!

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

stale[bot] commented 5 years ago

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.