Repository navigation
Fix Docker Compose private registry docs #12178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,57 +115,27 @@ They are always resolved relative to the directory where the compose file reside | |
| This can be used with `DockerComposeContainer` and `ComposeContainer`, but **only in the containerized Compose (not with `Local Compose` mode)**. | ||
|
|
||
| ## Using private repositories in Docker compose | ||
| When Docker Compose is used in container mode (not local), it needs to be made aware of Docker | ||
| settings for private repositories. | ||
| By default, those setting are located in `$HOME/.docker/config.json`. | ||
| When Docker Compose runs in container mode (not local), the Compose container has no access to your Docker | ||
| credentials. To make private images work anyway, Testcontainers pulls the images referenced by the Compose file | ||
| (and by any Dockerfiles it builds) itself before starting Compose, so Compose finds them locally. | ||
|
|
||
| There are 3 ways to specify location of the `config.json` for Docker Compose: | ||
| These pulls use the same [Docker registry authentication](../supported_docker_environment/index.md#docker-registry-authentication) | ||
| as any other image Testcontainers pulls, including credential stores and helpers such as `osxkeychain`. | ||
| To use credentials from a non-default location, do one of the following: | ||
|
|
||
| * Use `DOCKER_CONFIG_FILE` environment variable. | ||
| * Set the `DOCKER_CONFIG` environment variable to the **directory** containing your `config.json`. | ||
|
|
||
| `export DOCKER_CONFIG_FILE=/some/location/config.json` | ||
| `export DOCKER_CONFIG=/some/location` | ||
|
|
||
| * Use `dockerConfigFile` java property | ||
|
|
||
| `java -DdockerConfigFile=/some/location/config.json` | ||
| * Set the `DOCKER_AUTH_CONFIG` environment variable to the content of a `config.json`. | ||
|
|
||
| * Don't specify anything. In this case default location `$HOME/.docker/config.json`, if present, will be used. | ||
| * Don't specify anything. In this case `$HOME/.docker/config.json`, if present, will be used. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document the default config path as The default lookup reads
|
||
|
|
||
| !!! note "Docker Compose and Credential Store / Credential Helpers" | ||
| Modern Docker tends to store credentials using the credential store/helper mechanism rather than storing credentials in Docker's configuration file. So, your `config.json` may look something like: | ||
|
|
||
| ```json | ||
| { | ||
| "auths" : { | ||
| "https://index.docker.io/v1/" : { | ||
| } | ||
| }, | ||
| "credsStore" : "osxkeychain" | ||
| } | ||
| ``` | ||
|
|
||
| When run inside a container, Docker Compose cannot access the Keychain, thus making the configuration useless. | ||
| To work around this problem, there are two options: | ||
|
|
||
| ##### Putting auths in a config file | ||
| Create a `config.json` in separate location with real authentication keys, like: | ||
|
|
||
| ```json | ||
| { | ||
| "auths" : { | ||
| "https://index.docker.io/v1/" : { | ||
| "auth": "QWEADSZXC..." | ||
| } | ||
| }, | ||
| "credsStore" : "osxkeychain" | ||
| } | ||
| ``` | ||
| and specify the location to Testcontainers using any of the two first methods from above. | ||
|
|
||
| ##### Using 'local compose' mode | ||
|
|
||
| [Local Compose mode](#local-compose-mode), mentioned above, will allow compose to directly access the Docker auth system (to the same extent that running the `docker-compose` CLI manually works). | ||
|
|
||
| !!! note | ||
| This only works while image pulling is enabled, which is the default. If you disable it with `withPull(false)`, | ||
| Compose has to pull any missing images itself and cannot authenticate from inside its container. | ||
| In that case, use [Local Compose mode](#the-local-compose-mode), which lets Compose use your Docker credentials | ||
| directly, the same way running the `docker compose` CLI manually does. | ||
|
|
||
| ## Adding this module to your project dependencies | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qualify the Dockerfile pre-pull claim for
buildmappings withoutdockerfile.Testcontainers reads a service's Dockerfile for pre-pull only when the
buildsetting names it. Thebuild: ./dirform and abuildmapping withdockerfileare covered. Abuildmapping that sets onlycontextis not covered, because the parser skips the defaultDockerfile. A private base image in that Dockerfile is not pulled before Compose starts, and the build can fail.Either state this limitation in the private-repositories section, or make the parser read the default
Dockerfilewhen that key is absent. The documentation must not state that all Dockerfiles are covered.