Skip to content

[Bug]: TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX affects local Dockerfile #6413

Open

Description

@gaeljw

Module

Core

Testcontainers version

1.15.2

Using the latest Testcontainers version?

No

Host OS

Linux

Host Arch

x86

Docker version

Client: Docker Engine - Community
 Version:           20.10.22
 API version:       1.41
 Go version:        go1.18.9
 Git commit:        3a2c30b
 Built:             Thu Dec 15 22:28:45 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.22
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.9
  Git commit:       42c8b31
  Built:            Thu Dec 15 22:26:25 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.15
  GitCommit:        5b842e528e99d4d4c1686467debf2bd4b88ecd86
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

What happened?

Usage of TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX for image substitution affects the name given to local images as well.

For example, the following piece of code:

new ImageFromDockerfile("redis-sentinel")
  .withFileFromClasspath("Dockerfile", "Dockerfile")

Triggers the following error:

o.t.u.ImageNameSubstitutor - Using my.company.registry.net/redis-sentinel:latest as a substitute image for redis-sentinel:latest (using image substitutor: DefaultImageNameSubstitutor (composite of 'ConfigurationFileImageNameSubstitutor' and 'PrefixingImageNameSubstitutor'))

The local name redis-sentinel is replaced by my.company.registry.net/redis-sentinel:latest which doesn't make sense at all.

Relevant log output

No response

Additional Information

No response

Activity

  1. gaeljw commented on Jan 17, 2023

    @gaeljw
    Author

    Using new ImageFromDockerfile() (without giving a name to the image) works fine as a workaround.

  2. eddumelendez commented on Feb 6, 2024

    @eddumelendez
    Member

    ImageFromDockerfile doesn't consider the TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX value but GenericContainer does it. So, when building the image on-the-fly the image is created without TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX value but when trying to run the image, the image contains TESTCONTAINERS_HUB_IMAGE_NAME_PREFIX value.

  3. rpallares commented on Jan 31, 2025

    @rpallares

    I have the same comportment in .net

  4. marcosflobo commented on Mar 26, 2025

    @marcosflobo

    Is there any update on this?

  5. leo7martins commented on Nov 24, 2026

    @leo7martins

    Hi @eddumelendez, I'd like to work on this issue. I traced it to RemoteDockerImage.getImageName() applying the default substitutor to Future<String> images: ImageFromDockerfile builds and tags the unprefixed local name, but GenericContainer later resolves the prefixed name. I propose using ImageNameSubstitutor.noop() for future-backed images and adding Docker-free regression tests in RemoteDockerImageTest. I would use AI assistance and disclose it in the PR. Would you be happy with that approach before I proceed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions