testcontainers / testcontainers/testcontainers-java
TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX doesn't affect image location when using ImageFromDockerfile
Nessuno ha ancora preso questa issue.
- Lingua principale
- Java
- Stelle
- 8.7k
- Fork
- 1.9k
- Merge medio
- 2g 17h
- PR unite (30g)
- 9
Descrizione
Hi. I found that when I set env TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX=myrepo.com/ not all images are downloaded from our internal repository. In code we are having:
ImageFromDockerfile().withDockerfileFromBuilder {
it.from("consul:latest")
....
})
FromStatementTrait doesn't use ImageNameSubstitutor what cause that docker pull image from dockerhub.
I've made a fix https://github.com/lukidzi/testcontainers-java/tree/fix-missing-prefix, but one test doesn't pass. It is caused by specific image scratch. My change introduce .asCanonicalNameString() and that caused image path change from scratch to scratch:latest what cause the problem. I can prepare a pull request but I am not sure how to fix this specific test. It looks like some problem with not handling tag by docker-java?. https://github.com/lukidzi/testcontainers-java/blob/fix-missing-prefix/core/src/test/java/org/testcontainers/images/builder/ImageFromDockerfileTest.java
FROM scratch:latest
15:47:06.784 INFO org.testcontainers.images.builder.ImageFromDockerfile - Transferred 20 bytes to Docker daemon
15:47:06.855 ERROR 🐳 [localhost/testcontainers/8wafezi9leafaish] - 'scratch' is a reserved name
Could not build image: 'scratch' is a reserved name
com.github.dockerjava.api.exception.DockerClientException: Could not build image: 'scratch' is a reserved name
at com.github.dockerjava.api.command.BuildImageResultCallback.getImageId(BuildImageResultCallback.java:78)
at com.github.dockerjava.api.command.BuildImageResultCallback.awaitImageId(BuildImageResultCallback.java:50)
at org.testcontainers.images.builder.ImageFromDockerfile.resolve(ImageFromDockerfile.java:141)
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con FromStatementTrait e ImageFromDockerfile, quindi esegui core/src/test/java/org/testcontainers/images/builder/ImageFromDockerfileTest.java per riprodurre il comportamento del prefisso e il fallimento di scratch. Il lavoro è completo quando le immagini di base del Dockerfile utilizzano il prefisso dell’immagine configurato senza modificare la semantica riservata dell’immagine scratch.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- docker, java
- Ambito
- devops, testing-qa
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100