Skip to main content

prefect_docker.containers

Integrations with Docker Containers.

Functions

create_docker_container

Create a container without starting it. Similar to docker create. Args:
  • image: The image to run.
  • command: The command(s) to run in the container.
  • name: The name for this container.
  • detach: Run container in the background.
  • docker_host: Settings for interacting with a Docker host.
  • entrypoint: The entrypoint for the container.
  • environment: Environment variables to set inside the container, as a dictionary or a list of strings in the format [“SOMEVARIABLE=xxx”].
  • **create_kwargs: Additional keyword arguments to pass to client.containers.create.
Returns:
  • A Docker Container object.
Examples: Create a container with the Prefect image.

get_docker_container_logs

Get logs from this container. Similar to the docker logs command. Args:
  • container_id: The container ID to pull logs from.
  • docker_host: Settings for interacting with a Docker host.
  • **logs_kwargs: Additional keyword arguments to pass to client.containers.get(container_id).logs.
Returns:
  • The Container’s logs.
Examples: Gets logs from a container with an ID that starts with “c157”.

start_docker_container

Start this container. Similar to the docker start command. Args: Returns:
  • The Docker Container object.
Examples: Start a container with an ID that starts with “c157”.

stop_docker_container

Stops a container. Similar to the docker stop command. Args: Returns:
  • The Docker Container object.
Examples: Stop a container with an ID that starts with “c157”.

remove_docker_container

Remove this container. Similar to the docker rm command. Args: Returns:
  • The Docker Container object.
Examples: Removes a container with an ID that starts with “c157”.