diff --git a/docker.go b/docker.go index e3d5799ac5..9540cf3a1b 100644 --- a/docker.go +++ b/docker.go @@ -49,11 +49,6 @@ const ( packagePath = "github.com/testcontainers/testcontainers-go" logStoppedForOutOfSyncMessage = "Stopping log consumer: Headers out of sync" - - healthStatusNone = "" // default status for a container with no healthcheck - healthStatusHealthy = "healthy" // healthy container - healthStatusStarting = "starting" // starting container - healthStatusUnhealthy = "unhealthy" // unhealthy container ) var createContainerFailDueToNameConflictRegex = regexp.MustCompile("Conflict. The container name .* is already in use by container .*") diff --git a/reaper.go b/reaper.go index 87205d0ff1..4f288ed48d 100644 --- a/reaper.go +++ b/reaper.go @@ -4,6 +4,7 @@ import ( "bufio" "context" "fmt" + "github.com/docker/docker/api/types" "math/rand" "net" "strings" @@ -117,8 +118,11 @@ func lookUpReaperContainer(ctx context.Context, sessionID string) (*DockerContai return err } - if r.healthStatus != healthStatusHealthy && r.healthStatus != healthStatusNone { - return fmt.Errorf("container %s is not healthy, wanted status=%s, got status=%s", resp[0].ID[:8], healthStatusHealthy, r.healthStatus) + // if a health status is present on the container, and the container is not healthy, error + if r.healthStatus != "" { + if r.healthStatus != types.Healthy && r.healthStatus != types.NoHealthcheck { + return fmt.Errorf("container %s is not healthy, wanted status=%s, got status=%s", resp[0].ID[:8], types.Healthy, r.healthStatus) + } } reaperContainer = r