MCPcopy Index your code
hub / github.com/docker/docker-py / get_context

Method get_context

docker/context/api.py:73–98  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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):

Callers 4

test_lifecycleMethod · 0.80
get_current_contextMethod · 0.80
set_current_contextMethod · 0.80

Calls 2

get_current_context_nameFunction · 0.85
load_contextMethod · 0.80

Tested by 2

test_lifecycleMethod · 0.64