Skip to content

How to Specify Private Registries? #1689

@austin127001

Description

@austin127001

I would like to understand how I can explicitly pass Docker auth/registry configuration to testcontainers. I see a lot of settings are processed as part of docker-java but I can't seem to get them to work as documented.

What I'm attempting:

  • A gradle build occurs inside of a Docker container (I've read through: https://www.testcontainers.org/supported_docker_environment/continuous_integration/dind_patterns/)
    • The Docker unix socket is mounted into this container
    • The source-code for a given project is mounted in
    • The image does not contain a ~/.docker/config.json
    • Appropriate credentials, endpoints, etc. are passed in at container runtime (large org, multiple BUs)[HOW DO I DO THIS?]
  • DiniD is not an option
  • Never touch the outside world; all internal registry mirror/proxies

What I've tried:

  • Explicitly creating a ~/.docker/config.json inside of the container
    • No setting was picked up
  • Explicitly creating a config.json along with a DOCKER_CONFIG=....
    • No setting was picked up
  • Passing the settings as part of the gradle build (e.g. gradle build -Pregistry.url=... or gradle build -Dregistry.url
    • No setting was picked up
  • Creating a docker-java.properties (described: https://github.com/docker-java/docker-java#configuration)
    • No setting was picked up
  • Setting the values in the test explicitly (No such withRegistryUrl):
@ClassRule
	public static GenericContainer rabbitMq = new GenericContainer<>("<INTERNAL_URL>/rabbitmq:management-alpine")
			.withExposedPorts(5672,15672)
                        .withRegistryUrl("<INTERNAL_URL>")
                        .withRegistryEmail("[email protected]");

No matter the configurations described above, it always fails with:

gradle build --info
...
> Task :test
Excluding []
Caching disabled for task ':test' because:
  Build cache is disabled
Task ':test' is not up-to-date because:
  Task has failed previously.
Starting process 'Gradle Test Executor 1'. Working directory: /workspace Command: /usr/lib/jvm/java-11-openjdk-11.0.1.13-3.el7_6.x86_64/bin/java -Dorg.gradle.native=false @/tmp/gradle-worker-classpath9403681164797392133txt -Xmx512m -Dfile.encoding=US-ASCII -Duser.country=US -Duser.language=en -Duser.variant -ea worker.org.gradle.process.internal.worker.GradleWorkerMain 'Gradle Test Executor 1'
Successfully started process 'Gradle Test Executor 1'

test.containers.TestContainersTest STANDARD_OUT
    17:41:02.891 [Test worker] INFO  o.t.d.DockerClientProviderStrategy - Will use 'okhttp' transport
    17:41:13.062 [Test worker] ERROR o.t.d.EnvironmentAndSystemPropertyClientProviderStrategy - ping failed with configuration Environment variables, system properties and defaults. Resolved:
        dockerHost=unix:///var/run/docker.sock
        apiVersion='{UNKNOWN_VERSION}'
        registryUrl='https://index.docker.io/v1/'
        registryUsername='<BUILD_USER>'
        registryPassword='null'
        registryEmail='null'
        dockerConfig='DefaultDockerClientConfig[dockerHost=unix:///var/run/docker.sock,registryUsername=<BUILD_USER>,registryPassword=<null>,registryEmail=<null>,registryUrl=https://index.docker.io/v1/,dockerConfigPath=/workspace/config.json,sslConfig=<null>,apiVersion={UNKNOWN_VERSION},dockerConfig=<null>]'
     due to org.rnorth.ducttape.TimeoutException: Timeout waiting for result with exception
    org.rnorth.ducttape.TimeoutException: Timeout waiting for result with exception
...

tl;dr:
Can I see working code where the following have been set explicitly as part of a mvn/gradle build process?

dockerHost=
apiVersion=
registryUrl=
registryUsername=
registryPassword=
registryEmail=
dockerConfig=

Version Info:
testCompile "org.testcontainers:junit-jupiter:1.11.3"

------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          11.0.1 (Oracle Corporation 11.0.1+13-LTS)
OS:           Linux 3.10.0-957.1.3.el7.x86_64 amd64
docker version
Client:
 Version:           18.09.8
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        0dd43dd87f
 Built:             Wed Jul 17 17:40:31 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions