idmtools_platform_container.container_operations.docker_operations module#

Here we implement the ContainerPlatform docker operations.

Copyright 2021, Bill & Melinda Gates Foundation. All rights reserved.

idmtools_platform_container.container_operations.docker_operations.validate_container_running(platform, **kwargs) str[source]#

Check if the docker daemon is running, find existing container or start a new container. :param platform: Platform :param kwargs: keyword arguments used to expand functionality

Returns:

container id

idmtools_platform_container.container_operations.docker_operations.get_container(container_id) Any[source]#

Get the container object by container ID. :param container_id: container id

Returns:

container object

idmtools_platform_container.container_operations.docker_operations.find_container_by_image(image: str, include_stopped: bool = False) Dict[source]#

Find the containers that match the image. :param image: docker image :param include_stopped: bool, if consider the stopped containers or not

Returns:

dict of containers

idmtools_platform_container.container_operations.docker_operations.stop_container(container: str | Container, remove: bool = True) NoReturn[source]#

Stop a container. :param container: container id or container object to be stopped :param remove: bool, if remove the container or not

Returns:

No return

idmtools_platform_container.container_operations.docker_operations.stop_all_containers(containers: List[str | Container], keep_running: bool = True, remove: bool = True) NoReturn[source]#

Stop all containers. :param containers: list of container id or containers to be stopped :param keep_running: bool, if keep the running containers or not :param remove: bool, if remove the container or not

Returns:

No return

idmtools_platform_container.container_operations.docker_operations.restart_container(container: str | Container) NoReturn[source]#

Restart a container. :param container: container id or container object to be restarted

Returns:

No return

idmtools_platform_container.container_operations.docker_operations.sort_containers_by_start(containers: List[Container], reverse: bool = True) List[Container][source]#

Sort the containers by the start time. :param containers: list of containers :param reverse: bool, if sort in reverse order

Returns:

sorted list of containers

idmtools_platform_container.container_operations.docker_operations.get_containers(include_stopped: bool = False) Dict[source]#

Find the containers that match the image. :param include_stopped: bool, if consider the stopped containers or not

Returns:

dict of containers

idmtools_platform_container.container_operations.docker_operations.get_working_containers(container_id: str | None = None, entity: bool = False) List[Any][source]#

Get the working containers. :param container_id: Container ID :param entity: bool, if return the container object or container id

Returns:

list of working containers or IDs

idmtools_platform_container.container_operations.docker_operations.is_docker_installed() bool[source]#

Check if Docker is installed. :returns: True/False

idmtools_platform_container.container_operations.docker_operations.is_docker_daemon_running() bool[source]#

Check if the Docker daemon is running. :returns: True/False

idmtools_platform_container.container_operations.docker_operations.check_local_image(image_name: str) bool[source]#

Check if the image exists locally. :param image_name: image name

Returns:

True/False

idmtools_platform_container.container_operations.docker_operations.pull_docker_image(image_name, tag='latest') bool[source]#

Pull a docker image from IDM artifactory. :param image_name: image name :param tag: image tag

Returns:

True/False

idmtools_platform_container.container_operations.docker_operations.compare_mounts(mounts1: List[Dict], mounts2: List[Dict]) bool[source]#

Compare two sets of mount configurations. :param mounts1: container mounting configurations :param mounts2: container mounting configurations

Returns:

True/False

idmtools_platform_container.container_operations.docker_operations.compare_container_mount(container1: str | Container, container2: str | Container) bool[source]#

Compare the mount configurations of two containers. :param container1: container object or id :param container2: container object or id

Returns:

True/False

class idmtools_platform_container.container_operations.docker_operations.Job(container_id: str, process_line: str)[source]#

Bases: object

Running Job.

__init__(container_id: str, process_line: str)[source]#

Initialize Job. :param container_id: Container ID :param process_line: Process Input Line

item_id: str = None#
group_pid: int = None#
item_type: ItemType = None#
job_id: int = None#
container_id: str = None#
elapsed: str = None#
display()[source]#

Display Job for debugging usage.

idmtools_platform_container.container_operations.docker_operations.list_running_jobs(container_id: str, limit: int | None = None) List[Job][source]#

List all running jobs on the container. :param container_id: Container ID :param limit: number of jobs to view

Returns:

list of running jobs

idmtools_platform_container.container_operations.docker_operations.find_running_job(item_id: int | str, container_id: str | None = None) Job[source]#

Check item running on container. :param item_id: Experiment/Simulation ID or Running Job ID :param container_id: Container ID

Returns:

running Job