Classes for running a Gretel Job as a local container

class gretel_client.projects.docker.ContainerRun(job:

Runs a Gretel Job from a local container.


job – Job to run as docker container.

property active

Returns True if the container is running. False otherwise.

container_output_dir: Optional[str] = None

Output directory on the container where artifacts placed.

property container_status

Status from the running docker container.

Valid statuses include:

created, restarting, running, removing, paused, exited, or dead

If the container isn’t running, an “unknown” status will be returned.


Remove the docker container


Attempts to gracefully shutdown the container run.

image: str = None

The container image used for running the job


Checks to see if the container is ok.


ContainerRunError if there is a problem with the container.

model: Model = None

The model associated with the container run

output_dir: Optional[Path] = None

Local file path to save artifacts to.


Run job via a local container. This method is async and will return after the job has started.

If you wish to block until the container has finished, the wait method may be used.

stop(force: bool = False)

If there is a running container this command will stop that container.


force – If force is True, SIGKILL will be sent to the container, otherwise SIGTERM.

wait(timeout: int = 30)

Blocks until a running container has completed. If the container hasn’t started yet, we wait until a timeout interval is reached.


timeout – The time in seconds to wait for a container to start. If the timeout is reached, the function will return.

exception gretel_client.projects.docker.ContainerRunError
exception gretel_client.projects.docker.DockerEnvironmentError

Checks that the local docker env is configured.

  • DockerEnvironmentError if the docker environment isn't

  • configured correctly.

gretel_client.projects.docker.extract_container_path(container: docker.models.containers.Container, container_path: str, host_path: str)

Writes all files from a container path to a host path