MCPcopy
hub / github.com/serverless/serverless / removeContainer

Method removeContainer

packages/util/src/docker/index.js:74–89  ·  view source on GitHub ↗

* Stops and removes a container if it exists * @param {Object} params * @param {string} params.containerName - Name of the container to remove * @returns {Promise }

({ containerName })

Source from the content-addressed store, hash-verified

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

Callers 4

#startContainerMethod · 0.80

Calls 4

getContainerMethod · 0.95
debugMethod · 0.80
stopMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected