containers_run

Mixin to provide Container run() method.

class RunMixin[source]

Bases: object

Class providing run() method for ContainersManager.

run(image: str | Image, command: str | List[str] | None = None, stdout=True, stderr=False, remove: bool = False, **kwargs) Container | Generator[str, None, None] | Iterator[str][source]

Run a container.

By default, run() will wait for the container to finish and return its logs.

If detach=True, run() will start the container and return a Container object rather

than logs.

Parameters:
  • image – Image to run.

  • command – Command to run in the container.

  • stdout – Include stdout. Default: True.

  • stderr – Include stderr. Default: False.

  • remove – Delete container when the container’s processes exit. Default: False.

Keyword Arguments:

arguments. (- See the create() method for keyword) –

Returns:

  • When detach is True, return a Container

  • If stdout is True, include stdout from container in output

  • If stderr is True, include stderr from container in output

  • When stream is True, output from container is returned as a generator

  • Otherwise, an iterator is returned after container has finished

Raises:
  • ContainerError – when Container exists with a non-zero code

  • ImageNotFound – when Image not found by Podman service

  • APIError – when Podman service reports an error