Repository navigation
No such container error #4803
Copy link
Copy link
Closed
Description
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!?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
luis-alves commentedon Dec 28, 2021
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 commentedon 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 commentedon Jan 3, 2022
I'm on Fedora 35. What do you mean by "It might have even given you podman"? Can I use podman instead?
kiview commentedon 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 dockerdoes 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
NotFoundExceptionlikely was from Testcontainers not being able to start Ryuk. Also, see this PR for an explanation of the exception:#4842
moemen commentedon 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 containererror.Solution for me was to uninstall docker desktop and use docker engine instead.