Skip to content

[Bug]: Cannot build image (Creating images on-the-fly feature) #9782

@IvansPhoto

Description

@IvansPhoto

Module

Core

Testcontainers version

1.20.4

Using the latest Testcontainers version?

Yes

Host OS

Windows 11

Host Arch

x86-64

Docker version

4.37.1

What happened?

I got an error when I tried to build an image from a Dockerfile (a .NET application) located in another folder using the method public ImageFromDockerfile withDockerfile(Path dockerfile).
The Java test application uses Maven.
Testcontainers for .NET work well on the same laptop.

package com.example.project;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

import java.nio.file.Path;

import static org.junit.jupiter.api.Assertions.assertTrue;

@Testcontainers
public class ContainerTests {

    @Container
    private static final GenericContainer<?> appContainer = new GenericContainer<>(
            new ImageFromDockerfile("app-currency-rate-extractor")
                    .withDockerfile(Path.of("C:/Users/guteh/RiderProjects/currency-rates-api-testing/app/Web/Dockerfile").toAbsolutePath())
    ).withExposedPorts(80);

    @BeforeAll
    public static void initAll() {
        appContainer.start();
    }

    @Test
    void addsTwoNumbers() {
        assertTrue(appContainer.isRunning());
    }
}

Relevant log output

[docker-java-stream-253055544] ERROR com.github.dockerjava.api.async.ResultCallbackTemplate - Error during callback
com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"pull access denied for build, repository does not exist or may require 'docker login': denied: requested access to the resource is denied"}

	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:241) ~[testcontainers-1.20.4.jar:1.20.4]
	at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269) ~[testcontainers-1.20.4.jar:1.20.4]
	at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]

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