runner.docker_utils

Utility functions to deal with docker.

Module Contents

Functions

is_docker_working() → bool

Check if we can successfully connect to the docker daemon.

docker_has_experimental() → bool

Return True if the docker daemon has experimental mode enabled.

ensure_volumes_present()

Make sure the derex network necessary for our docker-compose files to

wait_for_service(service: str, max_seconds: int = 35) → int

With a freshly created container services might need a bit of time to start.

check_services(services: Iterable[str], max_seconds: int = 1) → bool

Check if the specified services are running and healthy.

load_dump(relpath)

Loads a mysql dump into the derex mysql database.

build_image(dockerfile_text: str, paths: List[str], tag: str, tag_final: bool = False, extra_opts: Dict = {})

Build a docker image. Prepares a build context (a tar stream)

pull_images(image_names: List[str])

Pull the given image to the local docker daemon.

image_exists(needle: str) → bool

If the given image tag exist in the local docker repository, return True.

get_running_containers() → Dict

get_exposed_container_names() → List

run_minio_shell(command: str = 'sh', tty: bool = True)

Invoke a minio shell

Attributes

client

api_client

logger

VOLUMES

runner.docker_utils.client[source]
runner.docker_utils.api_client[source]
runner.docker_utils.logger[source]
runner.docker_utils.VOLUMES[source]
runner.docker_utils.is_docker_working()bool[source]

Check if we can successfully connect to the docker daemon.

runner.docker_utils.docker_has_experimental()bool[source]

Return True if the docker daemon has experimental mode enabled. We use this to produce squashed images.

runner.docker_utils.ensure_volumes_present()[source]

Make sure the derex network necessary for our docker-compose files to work is in place.

runner.docker_utils.wait_for_service(service: str, max_seconds: int = 35)int[source]

With a freshly created container services might need a bit of time to start. This functions waits up to max_seconds seconds for the healthcheck on the container to report as healthy. Returns an exit code 0 or raises an exception:

  • RuntimeError is raised if the service container cannot be found or is not in a running state

  • NotImplementedError is raised if the service doesn’t define any healthcheck

  • TimeoutError is raised if the healtcheck doesn’t report as healthy in the max_seconds amount of time

runner.docker_utils.check_services(services: Iterable[str], max_seconds: int = 1)bool[source]

Check if the specified services are running and healthy. For every service it will retry for a max_seconds amount of time. Returns False if any of the service is unhealthy, True otherwise.

runner.docker_utils.load_dump(relpath)[source]

Loads a mysql dump into the derex mysql database.

runner.docker_utils.build_image(dockerfile_text: str, paths: List[str], tag: str, tag_final: bool = False, extra_opts: Dict = {})[source]

Build a docker image. Prepares a build context (a tar stream) based on the paths argument and includes the Dockerfile text passed in dockerfile_text.

runner.docker_utils.pull_images(image_names: List[str])[source]

Pull the given image to the local docker daemon.

runner.docker_utils.image_exists(needle: str)bool[source]

If the given image tag exist in the local docker repository, return True.

exception runner.docker_utils.BuildError[source]

Bases: RuntimeError

An error occurred while building a docker image

Initialize self. See help(type(self)) for accurate signature.

runner.docker_utils.get_running_containers()Dict[source]
runner.docker_utils.get_exposed_container_names()List[source]
runner.docker_utils.run_minio_shell(command: str = 'sh', tty: bool = True)[source]

Invoke a minio shell