gobbli.docker module¶
-
gobbli.docker.
format_container_output
(output)[source]¶ Format the output of a Docker container for printing or logging.
- Parameters
output¶ (
bytes
) – Raw bytes output by the container.- Return type
str
- Returns
Output formatted as a string.
-
gobbli.docker.
maybe_mount
(volumes, host_path, container_path, mode='rw')[source]¶ If the given host path is not None, mutate the volumes to add an appropriate mapping for the path. Otherwise, don’t modify the volumes.
-
gobbli.docker.
run_container
(client, image_tag, cmd, logger, **kwargs)[source]¶ Run a container, appropriately display/handle output, and remove after finishing. Resolve all host directories to be mounted as volumes in order to prevent errors related to docker mounting relative paths.
- Parameters
client¶ (
DockerClient
) – The Docker client to use to run the container.image_tag¶ (
str
) – Tag for the image to create the container from.cmd¶ (
str
) – Command to run in the container.logger¶ (
Logger
) – Logger which will be used to log debug information from the container.**kwargs¶ – Additional arguments to pass to
docker.models.containers.ContainerCollection.run()
.
- Return type
str
- Returns
A string containing all output from the container.