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

Method exec_start

docker/api/exec_api.py:118–176  ·  view source on GitHub ↗

Start a previously set up exec instance. Args: exec_id (str): ID of the exec instance detach (bool): If true, detach from the exec command. Default: False tty (bool): Allocate a pseudo-TTY. Default: False stream (bool)

(self, exec_id, detach=False, tty=False, stream=False,
                   socket=False, demux=False)

Source from the content-addressed store, hash-verified

116
117 @utils.check_resource('exec_id')
118 def exec_start(self, exec_id, detach=False, tty=False, stream=False,
119 socket=False, demux=False):
120 """
121 Start a previously set up exec instance.
122
123 Args:
124 exec_id (str): ID of the exec instance
125 detach (bool): If true, detach from the exec command.
126 Default: False
127 tty (bool): Allocate a pseudo-TTY. Default: False
128 stream (bool): Return response data progressively as an iterator
129 of strings, rather than a single string.
130 socket (bool): Return the connection socket to allow custom
131 read/write operations. Must be closed by the caller when done.
132 demux (bool): Return stdout and stderr separately
133
134 Returns:
135
136 (generator or str or tuple): If ``stream=True``, a generator
137 yielding response chunks. If ``socket=True``, a socket object for
138 the connection. A string containing response data otherwise. If
139 ``demux=True``, a tuple with two elements of type byte: stdout and
140 stderr.
141
142 Raises:
143 :py:class:`docker.errors.APIError`
144 If the server returns an error.
145 """
146 # we want opened socket if socket == True
147
148 data = {
149 'Tty': tty,
150 'Detach': detach
151 }
152
153 headers = {} if detach else {
154 'Connection': 'Upgrade',
155 'Upgrade': 'tcp'
156 }
157
158 res = self._post_json(
159 self._url('/exec/{0}/start', exec_id),
160 headers=headers,
161 data=data,
162 stream=True
163 )
164 if detach:
165 try:
166 return self._result(res)
167 finally:
168 res.close()
169 if socket:
170 return self._get_raw_response_socket(res)
171
172 output = self._read_from_socket(res, stream, tty=tty, demux=demux)
173 if stream:
174 return CancellableStream(output, res)
175 else:

Calls 7

CancellableStreamClass · 0.85
_post_jsonMethod · 0.80
_urlMethod · 0.80
_resultMethod · 0.80
_read_from_socketMethod · 0.80
closeMethod · 0.45