Skip to content

ImageFromDockerfile still fails if Dockerfile requires private base image #2575

@JakobFels

Description

@JakobFels

Hey,

Just gave 1.14.0 a spin to see if it fixes my issue with Dockerfiles requiring base images hosted in a private registry.
Unfortunately this is still not working.
What I saw from debugging a little:
It seems like the new logic is trying to pull too early,

  protected final String resolve() {
        Logger logger = DockerLoggerFactory.getLogger(dockerImageName);

        DockerClient dockerClient = DockerClientFactory.instance().client();

        dependencyImageNames.forEach(imageName -> {
            try {
                log.info("Pre-emptively checking local images for '{}', referenced via a Dockerfile. If not available, it will be pulled.", imageName);
                DockerClientFactory.instance().checkAndPullImage(dockerClient, imageName);
            } catch (Exception e) {
                log.warn("Unable to pre-fetch an image ({}) depended upon by Dockerfile - image build will continue but may fail. Exception message was: {}", imageName, e.getMessage());
            }
        });

           [... ommitted for brevity]

            BuildImageCmd buildImageCmd = dockerClient.buildImageCmd(in);
            configure(buildImageCmd);
           [...]
    }

notice how dependencyImageNames is iterated before the call to configure while configure is the method that will actually populate dependencyImageNames.

So running my tests after docker system prune -a still results in failure .

What I also noticed is that org.testcontainers.containers.GenericContainer#logger will trigger a build of the image in question.
This prevents using .withStartupAttempts(2) as a workaround

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions