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", "Meta
(cls, name=None)
| 71 | |
| 72 | @classmethod |
| 73 | def get_context(cls, name=None): |
| 74 | """Retrieves a context object. |
| 75 | Args: |
| 76 | name (str): The name of the context |
| 77 | |
| 78 | Example: |
| 79 | |
| 80 | >>> from docker.context import ContextAPI |
| 81 | >>> ctx = ContextAPI.get_context(name='test') |
| 82 | >>> print(ctx.Metadata) |
| 83 | { |
| 84 | "Name": "test", |
| 85 | "Metadata": {}, |
| 86 | "Endpoints": { |
| 87 | "docker": { |
| 88 | "Host": "unix:///var/run/docker.sock", |
| 89 | "SkipTLSVerify": false |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | """ |
| 94 | if not name: |
| 95 | name = get_current_context_name() |
| 96 | if name == "default": |
| 97 | return cls.DEFAULT_CONTEXT |
| 98 | return Context.load_context(name) |
| 99 | |
| 100 | @classmethod |
| 101 | def contexts(cls): |