MCPcopy
hub / github.com/serverless/serverless / getContainer

Method getContainer

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

* Gets a Docker container by name * @param {Object} params * @param {string} params.containerName - Name of the container * @returns {Promise }

({ containerName })

Source from the content-addressed store, hash-verified

56 * @returns {Promise<Dockerode.Container|null>}
57 */
58 async getContainer({ containerName }) {
59 const containers = await this.client.listContainers({ all: true })
60 const container = containers.find(
61 (c) =>
62 c.Names.includes(`/${containerName}`) ||
63 c.Names.includes(containerName),
64 )
65 return container ? this.client.getContainer(container.Id) : null
66 }
67
68 /**
69 * Stops and removes a container if it exists

Callers 2

removeContainerMethod · 0.95
getContainerIfExistsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected