autonomy_toolkit.containers.docker_client
#
Helpful utilities for interacting with docker.
Module Contents#
Classes#
Client interface for interacting with docker compose orchestration. |
- exception ContainerException(message: Any, stdout: str = None, stderr: str = None)[source]#
Bases:
Exception
Exception class that is used by the
ContainerClient
when an error occurs- Parameters:
message (Any) – The message to be stored in the base class Exception
stdout (str) – The stdout from the command
stderr (str) – The stderr from the command
- class DockerClient(config: autonomy_toolkit.utils.atk_config.ATKConfig, *, dry_run: bool = False, opts: List[str] = [], args: List[str] = [])[source]#
Client interface for interacting with docker compose orchestration.
- Parameters:
config (ATKConfig) – The ATK configuration object.
dry_run (bool) – Whether to actually run the commands or just print them. Use DEBUG logging level to see the commands.
opts (List[str]) – Options to pass to the
docker compose
command.args (List[str]) – Arguments to pass to the
docker compose <command>
command.
- attach() bool [source]#
Attach to a container.
NOTE: We assume a shell session is desired.
This is somewhat difficult, as we don’t know the default shell of the user in the container. We therefore have to determine this at runtime with a pretty nasty command.
- Returns:
bool – Whether the command succeeded.
- run_cmd(cmd, *args, without_ots: bool = False, **kwargs) bool [source]#
Run a command using the system wide
compose
commandAdditional positional args (
*args
) will be passed as command arguments when running the command. Named arguments will be passed tosubprocess.run()
(see their docs).- Parameters:
cmd (str) – The command to run.
- Returns:
Bool – Whether the command succeeded.