LocalDockerInstance#

class ansys.geometry.core.connection.docker_instance.LocalDockerInstance(port: int = DEFAULT_PORT, connect_to_existing_service: bool = True, restart_if_existing_service: bool = False, name: str | None = None, image: GeometryContainers | None = None)#

Instantiates a Geometry service as a local Docker container.

By default, if a container with the Geometry service already exists at the given port, PyAnsys Geometry connects to it. Otherwise, PyAnsys Geometry tries to launch its own service.

Parameters:
portint, optional

Localhost port to deploy the Geometry service on or the the Modeler interface to connect to (if it is already deployed). By default, the value is the one for the DEFAULT_PORT connection parameter.

connect_to_existing_servicebool, default: True

Whether the Modeler interface should connect to a Geometry service already deployed at the specified port.

restart_if_existing_servicebool, default: False

Whether the Geometry service (which is already running) should be restarted when attempting connection.

namestr or None, default: None

Name of the Docker container to deploy. The default is None, in which case Docker assigns it a random name.

imageGeometryContainers or None, default: None

The Geometry service Docker image to deploy. The default is None, in which case the LocalDockerInstance class identifies the OS of your Docker engine and deploys the latest version of the Geometry service for that OS.

Overview#

container

Docker container object that hosts the deployed Geometry service.

existed_previously

Flag indicating whether the container previously existed.

__DOCKER_CLIENT__

Docker client class variable.

docker_client

Get the initialized __DOCKER_CLIENT__ object.

is_docker_installed

Check a local installation of Docker engine is available and running.

Import detail#

from ansys.geometry.core.connection.docker_instance import LocalDockerInstance

Property detail#

property LocalDockerInstance.container: docker.models.containers.Container#

Docker container object that hosts the deployed Geometry service.

property LocalDockerInstance.existed_previously: bool#

Flag indicating whether the container previously existed.

Returns False if the Geometry service was effectively deployed by this class or True if it already existed.

Attribute detail#

LocalDockerInstance.__DOCKER_CLIENT__: docker.client.DockerClient = None#

Docker client class variable.

Notes

The default is None, in which case lazy initialization is used. __DOCKER_CLIENT__ is a class variable, meaning that it is the same variable for all instances of this class.

Method detail#

static LocalDockerInstance.docker_client() docker.client.DockerClient#

Get the initialized __DOCKER_CLIENT__ object.

Returns:
DockerClient

Initialized Docker client.

Notes

The LocalDockerInstance class performs a lazy initialization of the __DOCKER_CLIENT__ class variable.

static LocalDockerInstance.is_docker_installed() bool#

Check a local installation of Docker engine is available and running.

Returns:
bool

True if Docker engine is available and running, False otherwise.