containers_run¶
Mixin to provide Container run() method.
- class RunMixin[source]¶
Bases:
objectClass 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. In this case, if remove=True, run() will monitor and remove the container after it finishes running; the logs will be lost in this case.
- 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 on the client side when the container’s processes exit. The auto_remove flag is also available to manage the removal on the daemon side. Default: False.
- Keyword Arguments:
found. (- These args are directly used to pull an image when the image is not) – auth_config (Mapping[str, str]): Override the credentials that are found in the config for this request. auth_config should contain the username and password keys to be valid. platform (str): Platform in the format os[/arch[/variant]] policy (str): Pull policy. “missing” (default), “always”, “never”, “newer”
arguments. (- See the create() method for other 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