@lifeomic/test-tool-docker
Convenience methods for interacting with Docker
executeContainerCommand pullImage imageExists ensureImage getHostAddress
Container
executeContainerCommand
Executes the container with several convenience options.
ExecuteCommandConfig | Description |
---|---|
container | A dockerode container |
command | The command to be sent to the container |
environment | environment variables to be sent to the container. Should be in the format ENV_NAME=ENV_VALUE
|
stdin? | If set then the string is sent as an end command to the container stream |
Image
pullImage
Pulls the image into the current Docker environment
arg | Description |
---|---|
docker | A dockerode instance |
image | The image to be pulled. <image-name>[:<tag>]
|
imageExists
Returns if the image exists in the local docker environment.
arg | Description |
---|---|
docker | A dockerode instance |
image | The image to be checked. <image-name>[:<tag>]
|
ensureImage
Will pull the image from the remote repository if it isn't already present locally.
arg | Description |
---|---|
docker | A dockerode instance |
image | The image to be checked. <image-name>[:<tag>]
|
Utility methods
getHostAddress
Will return the Docker host address.
If process.env.DOCKER_HOST_ADDR
is set, then that value will be returned.
When running on MacOS and require('os').type() === 'Darwin'
then '127.0.0.1' will be returned.
Otherwise, we will start up an alpine image and return the default inet address.