container_manager¶
Classes
ContainerManager (docker_config, *args, **kwargs) |
Initializes the Container manager. |
-
class
remoteappmanager.docker.container_manager.
ContainerManager
(docker_config, *args, **kwargs)[source]¶ Bases:
remoteappmanager.logging.logging_mixin.LoggingMixin
Initializes the Container manager.
Parameters: docker_config (Dict) – A dictionary containing the keywords for the configuration of the docker client in agreement to docker py documentation. -
container_from_url_id
(url_id)[source]¶ Retrieves and returns the container by its url_id, if present. If not present, returns None.
-
container_port
= Int¶ The container (not host) port. We decided it’s 8888 by default. It will be mapped to a random port on the host, so that our reverse proxy can refer to it.
an int
Default: 8888
-
containers_from_filters
(filters)[source]¶ Returns the currently running containers for a given filter
Parameters: filters (dict) – A dictionary of filters as in dockerpy Returns: Return type: A list of Container objects, or an empty list if nothing is found.
-
containers_from_mapping_id
(user_name, mapping_id)[source]¶ Returns the currently running containers for a given user and mapping_id.
Parameters: Returns: Return type: A list of Container objects, or an empty list if nothing is found.
-
docker_client
= Instance¶ The asynchronous docker client.
an AsyncDockerClient
-
docker_config
= Dict¶ The docker client configuration
a dict
-
start_container
(user_name, image_name, mapping_id, base_urlpath, volumes, environment=None)[source]¶ Starts a container using the given image name.
Parameters: - user_name (string) – The name of the user
- image_name (string) – A string identifying the image name.
- mapping_id (str) – A generic id used to recognize the container. it is expected to be unique (and persistent) for a specific combination of docker image (i.e. application) and setup (i.e. configuration).
- base_urlpath (str) – The base urlpath for the current user.
- volumes (dict or None) – {volume_source: {‘bind’: volume_target, ‘mode’: volume_mode}
- environment (dict or None) – Contains additional keyvalue pairs that will be exported as environment variables inside the container.
Returns: Return type: A container object containing information about the started container.
Raises: OperationInProgres: – if the requested mapping id is already scheduled for addition
-
stop_and_remove_container
(container_id)[source]¶ Idempotent removal of a container by id. If the container is there, it will be removed. If it’s not there, the unexpected conditions will be logged.
Parameters: container_id (str) – A string containing the container identifier. Raises: OperationInProgres: – if the requested container id is already scheduled for removal.
-
Exceptions
OperationInProgress |
Exception raised when the operation for the requested image or container is already in progress. |