class documentation

class ContextAPI: (source)

View In Hierarchy

Context API. Contains methods for context management: create, list, remove, get, inspect.

Class Method contexts Context list. Returns: (Context): List of context objects. Raises: :py:class:`docker.errors.APIError` If the server returns an error.
Class Method create_context Creates a new context. Returns: (Context): a Context object. Raises: :py:class:`docker.errors.MissingContextParameter` If a context name is not provided. :py:class:`docker.errors.ContextAlreadyExists` If a context with the name already exists...
Class Method get_context Retrieves a context object. Args: name (str): The name of the context
Class Method get_current_context Get current context. Returns: (Context): current context object.
Class Method inspect_context Remove a context. Similar to the ``docker context inspect`` command.
Class Method remove_context Remove a context. Similar to the ``docker context rm`` command.
Class Method set_current_context Undocumented
Constant DEFAULT_CONTEXT Undocumented
@classmethod
def contexts(cls): (source)

Context list. Returns: (Context): List of context objects. Raises: :py:class:`docker.errors.APIError` If the server returns an error.

@classmethod
def create_context(cls, name, orchestrator=None, host=None, tls_cfg=None, default_namespace=None, skip_tls_verify=False): (source)

Creates a new context. Returns: (Context): a Context object. Raises: :py:class:`docker.errors.MissingContextParameter` If a context name is not provided. :py:class:`docker.errors.ContextAlreadyExists` If a context with the name already exists. :py:class:`docker.errors.ContextException` If name is default. Example: >>> from docker.context import ContextAPI >>> ctx = ContextAPI.create_context(name='test') >>> print(ctx.Metadata) { "Name": "test", "Metadata": {}, "Endpoints": { "docker": { "Host": "unix:///var/run/docker.sock", "SkipTLSVerify": false } } }

@classmethod
def get_context(cls, name=None): (source)

Retrieves a context object. Args: name (str): The name of the context Example: >>> from docker.context import ContextAPI >>> ctx = ContextAPI.get_context(name='test') >>> print(ctx.Metadata) { "Name": "test", "Metadata": {}, "Endpoints": { "docker": { "Host": "unix:///var/run/docker.sock", "SkipTLSVerify": false } } }

@classmethod
def get_current_context(cls): (source)

Get current context. Returns: (Context): current context object.

@classmethod
def inspect_context(cls, name='default'): (source)

Remove a context. Similar to the ``docker context inspect`` command. Args: name (str): The name of the context Raises: :py:class:`docker.errors.MissingContextParameter` If a context name is not provided. :py:class:`docker.errors.ContextNotFound` If a context with the name does not exist. Example: >>> from docker.context import ContextAPI >>> ContextAPI.remove_context(name='test') >>>

@classmethod
def remove_context(cls, name): (source)

Remove a context. Similar to the ``docker context rm`` command. Args: name (str): The name of the context Raises: :py:class:`docker.errors.MissingContextParameter` If a context name is not provided. :py:class:`docker.errors.ContextNotFound` If a context with the name does not exist. :py:class:`docker.errors.ContextException` If name is default. Example: >>> from docker.context import ContextAPI >>> ContextAPI.remove_context(name='test') >>>

@classmethod
def set_current_context(cls, name='default'): (source)

Undocumented

DEFAULT_CONTEXT = (source)

Undocumented

Value
Context('default', 'swarm')