Like ``attach``, but returns the underlying socket-like object for the HTTP request. Args: container (str): The container to attach to. params (dict): Dictionary of request parameters (e.g. ``stdout``, ``stderr``, ``stream``).
(self, container, params=None, ws=False)
| 68 | |
| 69 | @utils.check_resource('container') |
| 70 | def attach_socket(self, container, params=None, ws=False): |
| 71 | """ |
| 72 | Like ``attach``, but returns the underlying socket-like object for the |
| 73 | HTTP request. |
| 74 | |
| 75 | Args: |
| 76 | container (str): The container to attach to. |
| 77 | params (dict): Dictionary of request parameters (e.g. ``stdout``, |
| 78 | ``stderr``, ``stream``). |
| 79 | For ``detachKeys``, ~/.docker/config.json is used by default. |
| 80 | ws (bool): Use websockets instead of raw HTTP. |
| 81 | |
| 82 | Raises: |
| 83 | :py:class:`docker.errors.APIError` |
| 84 | If the server returns an error. |
| 85 | """ |
| 86 | if params is None: |
| 87 | params = { |
| 88 | 'stdout': 1, |
| 89 | 'stderr': 1, |
| 90 | 'stream': 1 |
| 91 | } |
| 92 | |
| 93 | if 'detachKeys' not in params \ |
| 94 | and 'detachKeys' in self._general_configs: |
| 95 | |
| 96 | params['detachKeys'] = self._general_configs['detachKeys'] |
| 97 | |
| 98 | if ws: |
| 99 | return self._attach_websocket(container, params) |
| 100 | |
| 101 | headers = { |
| 102 | 'Connection': 'Upgrade', |
| 103 | 'Upgrade': 'tcp' |
| 104 | } |
| 105 | |
| 106 | u = self._url("/containers/{0}/attach", container) |
| 107 | return self._get_raw_response_socket( |
| 108 | self.post( |
| 109 | u, None, params=self._attach_params(params), stream=True, |
| 110 | headers=headers |
| 111 | ) |
| 112 | ) |
| 113 | |
| 114 | @utils.check_resource('container') |
| 115 | def commit(self, container, repository=None, tag=None, message=None, |
nothing calls this directly
no test coverage detected