repro.common.docker#

class repro.common.docker.BuildDockerImageSubcommand(root, default_image)#
add_subparser(model, parser)#
run(args)#
class repro.common.docker.DockerContainer(image)#
run_command(**kwargs)#
repro.common.docker.build_image(root, image, build_args=None, silent=False)#
repro.common.docker.image_exists(image)#
repro.common.docker.make_volume_map(*volumes)#
repro.common.docker.pull_image(image)#

Pulls an image from Docker Hub.

Parameters

image (str) – The name of the image to pull.

repro.common.docker.remove_image(image, force=False)#
repro.common.docker.run_command(image, command, volume_map=None, stdout=True, stderr=True, silent=False, network_disabled=False, cuda=False)#

Runs a shell command in a Docker image.

Parameters
  • image (str) – The name of the Docker image

  • command (str) – The command to run

  • volume_map (Dict[str, str], default=None) – A mapping between host directories to container directories

  • stdout (bool, default=True) – Indicates the stdout stream should be returned

  • stderr (bool, default=True) – Indicates the stderr stream should be returned

  • silent (bool, default=False) – Indicates whether the stdout and stderr streams of the command should be written to stdout if stdout and stderr are True, respectively

  • network_disabled (bool, default=False) – Indicates the container’s network connection should be disabled

  • cuda (bool, default=False) – Indicates that the processes uses cuda, in which the runtime will be set to “nvidia”

Returns

The stdout and stderr streams of the command if stdout and stderr are True, respectively. There appears to be a bug in the docker package related to collecting the full stdout and stderr streams, so we do not recommend relying on these streams.

Return type

str