* Gets a Docker container by name * @param {Object} params * @param {string} params.containerName - Name of the container * @returns {Promise }
({ containerName })
| 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 |
no outgoing calls
no test coverage detected