testcontainers / testcontainers/testcontainers-java

Feature request: support `docker.io/*` images to use auth config from `~/.docker/config.json`

Aperta
#4,474 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Java
Stelle
8.7k
Fork
1.9k
Merge medio
2g 17h
PR unite (30g)
9

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia tracciando RegistryAuthLocator e AuthDelegatingDockerClientConfig, i componenti nominati nei log, e confronta il modo in cui vengono risolti docker.io e index.docker.io. Il lavoro è completato quando le credenziali di ~/.docker/config.json vengono utilizzate durante il pull di immagini qualificate con docker.io, con test che coprono questa forma dell’immagine.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
docker, java
Ambito
authentication, devops
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.