Skip to content

No such container error #4803

Closed
Closed

Description

@luis-alves

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!?

Activity

  1. luis-alves commented on Dec 28, 2021

    @luis-alves
    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.

  2. kiview commented on Jan 3, 2022

    @kiview
    Member

    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.

  3. luis-alves commented on Jan 3, 2022

    @luis-alves
    Author

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

  4. kiview commented on Jan 3, 2022

    @kiview
    Member

    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

  5. moemen commented on Jan 4, 2023

    @moemen

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions