* Gets a container if it exists, returns null if it doesn't * @param {Object} params * @param {string} params.containerName - Name of container to get * @returns {Promise } Container object or null if not found
({ containerName })
| 37 | * @returns {Promise<Container|null>} Container object or null if not found |
| 38 | */ |
| 39 | async getContainerIfExists({ containerName }) { |
| 40 | try { |
| 41 | const container = this.client.getContainer(containerName) |
| 42 | await container.inspect() |
| 43 | return container |
| 44 | } catch (error) { |
| 45 | if (error.statusCode === 404) { |
| 46 | return null |
| 47 | } |
| 48 | throw error |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Gets a Docker container by name |
no test coverage detected