For GitLab CI to use container registries requiring authentication, a common approach is to set the DOCKER_AUTH_CONFIG environment variable. This variable value is the same as that of the contents of ~/.docker/config.json.
Therefore, in GitLab CI today, to use testcontainers one has to write the contents of DOCKER_AUTH_CONFIG to ~/.docker/config.json before running the testcontainers job. For example, here's a GitLab CI job using the example private docker registry at my.private.registry:
build:
stage: build
services:
- name: my.private.registry/docker:dind
alias: docker
variables:
# Instruct Testcontainers to use the daemon of DinD.
DOCKER_HOST: "tcp://docker:2375"
DOCKER_TLS_CERTDIR: ""
TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX: my.private.registry/
image: my.private.registry/adoptopenjdk:11-jdk-hotspot
before_script:
- mkdir -p "${HOME}/.docker" && echo "${DOCKER_AUTH_CONFIG}" > "${HOME}/.docker/config.json" # Testcontainers doesn't read the DOCKER_AUTH_CONFIG environment variable, only ~/.docker/config.json
script:
- ./gradlew build
It would be nice for testcontainers to support getting container registry authentication information from DOCKER_AUTH_CONFIG which would make it easier to use with GitLab CI.
For GitLab CI to use container registries requiring authentication, a common approach is to set the
DOCKER_AUTH_CONFIGenvironment variable. This variable value is the same as that of the contents of~/.docker/config.json.Therefore, in GitLab CI today, to use testcontainers one has to write the contents of
DOCKER_AUTH_CONFIGto~/.docker/config.jsonbefore running the testcontainers job. For example, here's a GitLab CI job using the example private docker registry atmy.private.registry:It would be nice for testcontainers to support getting container registry authentication information from
DOCKER_AUTH_CONFIGwhich would make it easier to use with GitLab CI.