testcontainers / testcontainers/testcontainers-java
Feature request: support `docker.io/*` images to use auth config from `~/.docker/config.json`
まだ誰も着手していません。
- 主要言語
- Java
- スター
- 8.7k
- フォーク
- 1.9k
- 平均マージ
- 2日 17時間
- マージ済み PR(30日)
- 9
説明
Version: org.testcontainers:testcontainers-bom:1.16.0
This works fine:
new GenericContainer<>("amazon/dynamodb-local:1.16.0")
I've been seeing more recommendations to prefer fully qualified docker images (e.g. podman), so I switched to:
new GenericContainer<>("docker.io/amazon/dynamodb-local:1.16.0")
And then errors started occurring during my CI build.
I eventually figured out that the auth config was not being picked up:
[Test worker] DEBUG org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: docker.io/amazon/dynamodb-local:1.16.0
[Test worker] DEBUG org.testcontainers.images.AbstractImagePullPolicy - Using locally available and not pulling image: docker.io/amazon/dynamodb-local:1.16.0
[Test worker] INFO 🐳 [docker.io/amazon/dynamodb-local:1.16.0] - Creating container for image: docker.io/amazon/dynamodb-local:1.16.0
[Test worker] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: docker.io/amazon/dynamodb-local:1.16.0 at registry: docker.io
[Test worker] DEBUG org.testcontainers.utility.RegistryAuthLocator - RegistryAuthLocator has configFile: /home/builder/.docker/config.json (exists) and commandPathPrefix:
[Test worker] DEBUG org.testcontainers.utility.RegistryAuthLocator - registryName [docker.io] for dockerImageName [docker.io/amazon/dynamodb-local:1.16.0]
[Test worker] DEBUG org.testcontainers.utility.RegistryAuthLocator - No matching Auth Configs - falling back to defaultAuthConfig [null]
So I switched to index.docker.io, and it worked.
new GenericContainer<>("index.docker.io/amazon/dynamodb-local:1.16.0"):
[Test worker] DEBUG org.testcontainers.shaded.com.github.dockerjava.core.command.AbstrDockerCmd - Cmd: index.docker.io/amazon/dynamodb-local:1.16.0
[Test worker] DEBUG org.testcontainers.images.AbstractImagePullPolicy - Using locally available and not pulling image: index.docker.io/amazon/dynamodb-local:1.16.0
[Test worker] INFO 🐳 [index.docker.io/amazon/dynamodb-local:1.16.0] - Creating container for image: index.docker.io/amazon/dynamodb-local:1.16.0
[Test worker] DEBUG org.testcontainers.dockerclient.AuthDelegatingDockerClientConfig - Delegate call to effectiveAuthConfig failed with cause: 'Invalid repository name, try "amazon/dynamodb-local" instead'. Resolution of auth config will continue using RegistryAuthLocator.
[Test worker] DEBUG org.testcontainers.utility.RegistryAuthLocator - Looking up auth config for image: index.docker.io/amazon/dynamodb-local:1.16.0 at registry: index.docker.io
[Test worker] DEBUG org.testcontainers.utility.RegistryAuthLocator - Cached auth found: [AuthConfig{username=redacted, password=hidden non-blank value, auth=hidden non-blank value, email=null, registryAddress=https://index.docker.io/v1/, registryToken=blank}]
However, this is out of line with the docker cli, which does read from the ~/.docker/config.json.
If I change the https://index.docker.io/v1/ auth value and try to pull via:
docker -D pull docker.io/amazon/dynamodb-local:1.16.0
It fails with:
Error response from daemon: Head "https://registry-1.docker.io/v2/amazon/dynamodb-local/manifests/1.16.0": unauthorized: incorrect username or password
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、ログで名前が挙げられているコンポーネントである RegistryAuthLocator と AuthDelegatingDockerClientConfig を追跡し、docker.io と index.docker.io がどのように解決されるかを比較します。docker.io で修飾されたイメージを pull する際に ~/.docker/config.json の認証情報が使用され、そのイメージ形式を対象とするテストがあれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- docker, java
- 領域
- authentication, devops
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 55/100