diff --git a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_aggregator_functions/create_logs_aggregator.go b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_aggregator_functions/create_logs_aggregator.go index bd667ebdfc..c6349f9b03 100644 --- a/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_aggregator_functions/create_logs_aggregator.go +++ b/container-engine-lib/lib/backend_impls/docker/docker_kurtosis_backend/logs_aggregator_functions/create_logs_aggregator.go @@ -32,11 +32,21 @@ func CreateLogsAggregator( } if found { logrus.Debugf("Found existing logs aggregator; cannot start a new one.") - logsAggregatorObj, _, err := getLogsAggregatorObjectAndContainerId(ctx, dockerManager) + logsAggregatorObj, containerId, err := getLogsAggregatorObjectAndContainerId(ctx, dockerManager) if err != nil { return nil, nil, stacktrace.Propagate(err, "An error occurred getting existing logs aggregator.") } - return logsAggregatorObj, nil, nil + removeCtx := context.Background() + removeLogsAggregatorContainerFunc := func() { + if err := dockerManager.RemoveContainer(removeCtx, containerId); err != nil { + logrus.Errorf( + "Something failed while trying to remove the logs aggregator container with ID '%v'. Error was:\n%v", + containerId, + err) + logrus.Errorf("ACTION REQUIRED: You'll need to manually remove the logs aggregator server with Docker container ID '%v'!!!!!!", containerId) + } + } + return logsAggregatorObj, removeLogsAggregatorContainerFunc, nil } logsAggregatorNetwork, err := shared_helpers.GetEngineAndLogsComponentsNetwork(ctx, dockerManager)