[Feature]: TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX should be respected in Dockerfile when using ImageFromDockerfile
I maintainer di solito rispondono entro 1 giorno
@Bembaby ci sta già lavorando.
Dal 21/11/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 56/100
Direzione di ricerca
Start by tracing how ImageFromDockerfile handles Dockerfile FROM instructions and where TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX is applied to image names. Check existing tests for image name substitution and add coverage for a registry image reference and a multi-stage build, where the later FROM base reference should remain unchanged. Done means external base images use the configured prefix while stage references remain intact.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Module
Core
Testcontainers version
2.0.5
Using the latest Testcontainers version?
Yes
Host OS
Windows
Host Arch
x86-64
Docker version
Client:
Version: 29.9.2
API version: 1.56
Go version: go1.26.10
Git commit: a82e528
Built: Tue Oct 20 19:44:07 2026
OS/Arch: windows/amd64
Context: desktop-linux
Server: Docker Desktop 4.97.0 (244584)
Engine:
Version: 29.9.2
API version: 1.56 (minimum version 1.40)
Go version: go1.26.10
Git commit: 0367cbe
Built: Tue Oct 20 18:45:02 2026
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: v2.4.2
GitCommit: b7a25261e029d68978bbf290df0a62fc819b3c51
runc:
Version: 1.5.2
GitCommit: v1.5.2-0-g29dd3dc2
docker-init:
Version: 0.19.0
GitCommit: de40ad0
What happened?
using the following code
new GenericContainer<>(
new ImageFromDockerfile("localhost/testcontainers/sshd-base", true).
withFileFromClasspath(".", "/docker/simpleImage").
withTarget(target)).
withExposedPorts(22);
and a dockerfile like
FROM ubuntu:22.04 AS base
# install SSHD
RUN apt update -y && \
apt install -y \
openssh-server \
locales \
ucommon-utils \
coreutils
# Create an SSH user
RUN useradd -rm -d /home/foo -s /bin/bash -g root -G sudo -u 1000 foo
# Set the SSH user's password (replace "password" with your desired password)
RUN echo 'foo:beer' | chpasswd
# force X25519 which is not FIPS compliant
RUN echo "KexAlgorithms curve25519-sha256,[email protected]" >> /etc/ssh/sshd_config
RUN echo 'HostKeyAlgorithms rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256' >> /etc/ssh/sshd_config
# Allow SSH access
RUN mkdir /var/run/sshd
USER foo
COPY --from=eclipse-temurin:17.0.4.1_1-jdk /opt/java/openjdk /usr/java/latest
# Expose the SSH port
EXPOSE 22
COPY rsa2048.pub.ssh rsa2048.pub.ssh
RUN mkdir /home/foo/.ssh/
RUN cat rsa2048.pub.ssh >> /home/foo/.ssh/authorized_keys
USER root
# Start SSH server on container startup
CMD ["/usr/sbin/sshd", "-D"]
FROM base AS ed25519
#RUN echo 'HostKeyAlgorithms ssh-ed25519' >> /etc/ssh/sshd_config
RUN sed -i 's/HostKeyAlgorithms.*/HostKeyAlgorithms ssh-ed25519/g' /etc/ssh/sshd_config
FROM base AS fips
RUN sed -i 's/KexAlgorithms.*/KexAlgorithms diffie-hellman-group14-sha256,diffie-hellman-group-exchange-sha256/g' /etc/ssh/sshd_config
When used with TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX=proxy.docker.xxx.com/
it is expected that test containers overrides the FROM in the dockerfiles so that images are downloaded from the defined override location
e.g.
FROM ubuntu:22.04 AS base -> FROM proxy.docker.xxx.com/ubuntu:22.04 AS base
subsquent FROM base as that is multisage reference should remain unchanged
However things remain unchanged and the ubuntu image is pulled from dockerhub.
Relevant log output
INFO: Found Docker environment with local Npipe socket (npipe:////./pipe/docker_engine)
Nov 19, 2026 6:29:24 PM org.testcontainers.DockerClientFactory client
INFO: Docker host IP address is 192.168.176.1
Nov 19, 2026 6:29:24 PM org.testcontainers.DockerClientFactory client
INFO: Connected to docker:
Server Version: 29.9.2
API Version: 1.56
Operating System: Docker Desktop
Total Memory: 31882 MB
Labels:
com.docker.desktop.address=npipe://\\.\pipe\docker_cli
Nov 19, 2026 6:29:24 PM org.testcontainers.images.PullPolicy defaultPolicy
INFO: Image pull policy will be performed by: DefaultPullPolicy()
Nov 19, 2026 6:29:24 PM org.testcontainers.utility.ImageNameSubstitutor instance
INFO: Image name substitution will be performed by: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor')
Nov 19, 2026 6:29:24 PM org.testcontainers.utility.ImageNameSubstitutor$LogWrappedImageNameSubstitutor apply
INFO: Using proxy.docker.xxx.com/testcontainers/ryuk:0.14.0 as a substitute image for testcontainers/ryuk:0.14.0 (using image substitutor: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor'))
Nov 19, 2026 6:29:24 PM org.testcontainers.containers.GenericContainer tryStart
INFO: Creating container for image: proxy.docker.xxx.com/testcontainers/ryuk:0.14.0
Nov 19, 2026 6:29:24 PM org.testcontainers.containers.GenericContainer tryStart
INFO: Container proxy.docker.xxx.com/testcontainers/ryuk:0.14.0 is starting: 4565e6b6e1e883c29c7f04489c0dba8daad32098d8e14894a7ee6929b2c60736
Nov 19, 2026 6:29:24 PM org.testcontainers.containers.GenericContainer tryStart
INFO: Container proxy.docker.xxx.com/testcontainers/ryuk:0.14.0 started in PT0.5269617S
Nov 19, 2026 6:29:24 PM org.testcontainers.utility.RyukResourceReaper init
INFO: Ryuk started - will monitor and terminate Testcontainers containers on JVM exit
Nov 19, 2026 6:29:24 PM org.testcontainers.DockerClientFactory client
INFO: Checking the system...
Nov 19, 2026 6:29:24 PM org.testcontainers.DockerClientFactory check
INFO: ?? Docker server version should be at least 1.6.0
Nov 19, 2026 6:29:24 PM org.testcontainers.images.builder.ImageFromDockerfile resolve
INFO: Transferred 0 bytes to Docker daemon
Nov 19, 2026 6:29:24 PM org.testcontainers.containers.GenericContainer tryStart
INFO: Creating container for image: localhost/testcontainers/sshd-base:latest
Nov 19, 2026 6:29:24 PM org.testcontainers.utility.RegistryAuthLocator runCredentialProvider
INFO: Credential helper/store (docker-credential-desktop) does not have credentials for localhost
Nov 19, 2026 6:29:24 PM org.testcontainers.containers.GenericContainer tryStart
INFO: Container localhost/testcontainers/sshd-base:latest is starting: f71c87b66355121882b46e79de405239338b6c75880ba9b30c180c7a24ad13b4
Nov 19, 2026 6:29:25 PM org.testcontainers.containers.GenericContainer tryStart
INFO: Container localhost/testcontainers/sshd-base:latest started in PT0.4725188S
Additional Information
No response
- Lingua principale
- Java
- Stelle
- 8.8k
- Fork
- 2k
- Merge medio
- 2g 1h
- PR unite (30g)
- 11
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Include un Dockerfile o un file Docker Compose
- Ha un modello di pull request
- Leggi 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.
Altre issue di testcontainers/testcontainers-java
-
[Bug]: WaitStrategyTarget Handles Multiple Ports Differently to DocumentationForse già presa @suvvvv l’ha presa 2 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
testcontainers/testcontainers-java#12196 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: DockerImageName treats uppercase registry names as repository pathsForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
testcontainers/testcontainers-java#12186 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: withStartupTimeout() changes the startup timeout of all containers that use the default wait strategyForse già presa @aymenjamaaoui l’ha presa 18 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
testcontainers/testcontainers-java#12171 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Enhancement]: Document why singleton containers are required under Spring's test context cachingForse già presa @zakaullah075 l’ha presa 111 giorni fa. Apertatype/enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
testcontainers/testcontainers-java#11967 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Cannot reuse Selenium BrowserWebDriverContainers under LinuxForse già presa @kdelay l’ha presa 132 giorni fa. Apertatype/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
testcontainers/testcontainers-java#11941 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di testcontainers/testcontainers-java
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
erkamyaman/rust-anything#1381 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 80/100
java-native-access/jna#1757 ·