pi_dashboard.docker_container_handler

Docker container management handler.

Classes

DockerContainerHandler()

Handler for Docker container operations.

class pi_dashboard.docker_container_handler.DockerContainerHandler[source]

Handler for Docker container operations.

__init__()[source]

Initialize the DockerContainerHandler.

list_containers()[source]

List all Docker containers.

Return list[DockerContainer]:

List of containers

Return type:

list[DockerContainer]

start_container(container_id)[source]

Start a Docker container.

Parameters:

container_id (str) – The container ID to start

Return str:

The name of the started container

Return type:

str

stop_container(container_id, timeout)[source]

Stop a Docker container.

Parameters:
  • container_id (str) – The container ID to stop

  • timeout (int) – Timeout in seconds before forcefully killing the container

Return str:

The name of the stopped container

Return type:

str

restart_container(container_id, timeout)[source]

Restart a Docker container.

Parameters:
  • container_id (str) – The container ID to restart

  • timeout (int) – Timeout in seconds before forcefully killing the container

Return str:

The name of the restarted container

Return type:

str

update_container(container_id, timeout)[source]

Update a Docker container by pulling latest image and recreating it.

Parameters:
  • container_id (str) – The container ID to update

  • timeout (int) – Timeout in seconds before forcefully killing the container

Return tuple[str, str]:

Tuple of (container_name, new_container_id)

Return type:

tuple[str, str]

get_container_logs(container_id, lines)[source]

Get logs for a Docker container.

Parameters:
  • container_id (str) – The container ID

  • lines (int) – Number of log lines to retrieve (tail)

Return list[str]:

List of log lines

Return type:

list[str]