Skip to content

Commit

Permalink
fix: make removal of containers more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
m-raab committed Nov 28, 2023
1 parent d3701a1 commit 35ee95e
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package com.intershop.gradle.icm.docker.tasks

import com.github.dockerjava.api.exception.ConflictException
import com.github.dockerjava.api.exception.NotFoundException
import org.gradle.api.model.ObjectFactory
import javax.inject.Inject

Expand All @@ -37,8 +39,13 @@ open class RemoveContainerByName
removeContainerCmd.withForce(true)

logger.quiet("Removing container with ID '${it}'('${containerName.get()}').")

removeContainerCmd.exec()
try {
removeContainerCmd.exec()
} catch(ex: ConflictException) {
logger.info("Removal of ${it} is in progress. (${ex.message})")
} catch(ex: NotFoundException) {
logger.info("Can not find ${it}. (${ex.message})")
}
}
}
}

0 comments on commit 35ee95e

Please sign in to comment.