// RemoveContainer removes a container func RemoveContainer(logger *log.Entry, client client.DockerClient, containerID string, expectContainer bool) { logger.Debug("Removing container") err := client.RemoveContainer(docker.RemoveContainerOptions{ ID: containerID, RemoveVolumes: true, }) switch err.(type) { case *docker.NoSuchContainer: if !expectContainer { return } case nil: return } logger.WithFields(log.Fields{"container": containerID}).Warnf( "Failed to remove container: %s", err) }