* Stops and removes a container if it exists * @param {Object} params * @param {string} params.containerName - Name of the container to remove * @returns {Promise }
({ containerName })
| 72 | * @returns {Promise<void>} |
| 73 | */ |
| 74 | async removeContainer({ containerName }) { |
| 75 | const container = await this.getContainer({ containerName }) |
| 76 | if (container) { |
| 77 | this.logger.debug(`Removing container: ${containerName}`) |
| 78 | try { |
| 79 | await container.stop() |
| 80 | } catch (error) { |
| 81 | // Container might already be stopped |
| 82 | this.logger.debug( |
| 83 | 'Container already stopped or error stopping:', |
| 84 | error.message, |
| 85 | ) |
| 86 | } |
| 87 | await container.remove() |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * Gets the size of a Docker image in MB |
no test coverage detected