Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such container error #4803

Closed
luis-alves opened this issue Dec 27, 2021 · 5 comments
Closed

No such container error #4803

luis-alves opened this issue Dec 27, 2021 · 5 comments

Comments

@luis-alves
Copy link

Spring boot versions: 2.5.3
testcontainers version: 1.16.2
Added dependencies:

        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>postgresql</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>

When I run the below integration test it gives the following error:

com.github.dockerjava.api.exception.NotFoundException: Status 404: {"message":"No such container: 28b30f05bc53b19fae5f11daa9244e28f1eca57ceee6eb11558f1e730341c7f1"}

@ActiveProfiles("it")
@Testcontainers
//@formatter:off
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
                classes = RestApplication.class) //@formatter:on
@TestInstance(TestInstance.Lifecycle.PER_METHOD)
class DummyResourceIT {

    private static String BASE_PATH;

    @Container
    public static PostgreSQLContainer container = new PostgreSQLContainer("postgres:latest")
            .withUsername("dummyusername")
            .withPassword("dummypassword")
            .withDatabaseName("dummydb");

    @DynamicPropertySource
    static void properties(DynamicPropertyRegistry registry) {
        registry.add("spring.datasource.url", container::getJdbcUrl);
        registry.add("spring.datasource.username", container::getUsername);
        registry.add("spring.datasource.password", container::getPassword);
    }

    @LocalServerPort
    private int serverPort;

    @BeforeEach
    void setUp() {
        BASE_PATH = "http://localhost:" + serverPort + "/api";
    }

    @Test()
    void should_pass() {
        String url = BASE_PATH + "/v1/dummy";
        
        //@formatter:off
        given()
            .contentType(MediaType.APPLICATION_JSON_VALUE)
        .when()
            .get(url)
        .then()
            .statusCode(200)
            .log()
            .all()
            .body("size()", Matchers.equalTo(0));
        //@formatter:on
    }

What I'm doing wrong!?

@luis-alves
Copy link
Author

I managed to run the project in a virtual box, but this time with the official Docker engine, instead of the one provided by dnf packager, and it ran has expected. So I'm closing this issue.

@kiview
Copy link
Member

kiview commented Jan 3, 2022

Thanks for reporting and closing again with your fix. Indeed, we generally only support the official Docker packages, since some distro packages have a tendency to have strange quirks.

Since you are using dnf, were you on Fedora or RHEL? It might have even given you podman, not sure about their behavior at the moment.

@luis-alves
Copy link
Author

I'm on Fedora 35. What do you mean by "It might have even given you podman"? Can I use podman instead?

@kiview
Copy link
Member

kiview commented Jan 3, 2022

Since podman is not yet a fully compatible Docker replacement, podman does not work with Testcontainers. Also, see our blog post with some insights on this topic.

That being said, I just checked that dnf install docker does indeed install Docker on Fedora 35. So if the distro shipped Docker package does not work with Testcontainers, the issue should be somewhere else. If you are interested in resolving this, you can provide more Testcontainers logs.

However, I'd suggest continuing using the official Docker packages instead.

The NotFoundException likely was from Testcontainers not being able to start Ryuk. Also, see this PR for an explanation of the exception:
#4842

@moemen
Copy link

moemen commented Jan 4, 2023

I had the same issue on fedora 37 and the official docker desktop downloaded from docker website.

Problem was that docker desktop was returning success response to createContainer request and actually return an id, but I couldn't find that container anywhere or any logs related to it. Then the failure happens on startContainer call with the No such container error.

Solution for me was to uninstall docker desktop and use docker engine instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants