-
Notifications
You must be signed in to change notification settings - Fork 178
Closed
Description
See the following context.
However, this can't handle the case where an existing container is stopped. It would then failed with:
called `Result::unwrap()` on an `Err` value: Client(CreateContainer(DockerResponseServerError { status_code: 409, message: "Conflict. The container name \"/postgres\" is already in use by container \"5d2940fb2bd042cf859598932aae34aa5004b19d38797165806282b4ada66157\". You have to remove (or rename) that container to be able to reuse that name." }))
thread 'test_simple_pubsub' panicked at tests/toolkit/src/container.rs:150:10:
called `Result::unwrap()` on an `Err` value: Client(CreateContainer(DockerResponseServerError { status_code: 409, message: "Conflict. The container name \"/postgres\" is already in use by container \"5d2940fb2bd042cf859598932aae34aa5004b19d38797165806282b4ada66157\". You have to remove (or rename) that container to be able to reuse that name." }))
I resolve this issue in my bollard based solution by removing a stopped container with the same name, but not sure how to make it more smoothly in testcontainers.
Anyway, this can be a follow-up to improved:
async fn maybe_remove_container(&self, docker: &Docker, container_name: &str) {
let options = Some(RemoveContainerOptions {
v: true,
force: true,
link: false,
});
// best effort to remove existing container; ignore errors
let _ = docker.remove_container(container_name, options).await;
}Originally posted by @tisonkun in #887 (comment)
stopped container
This is common when a lasting test container gets stopped during the dev machine reboot.
Originally posted by @tisonkun in #887 (comment)
Metadata
Metadata
Assignees
Labels
No labels