exec: fix running with detach=True

Fixes #1271

Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
This commit is contained in:
Tomas Tomecek 2016-10-26 16:58:27 +02:00
parent 6a16edee3e
commit 515db1f6fd
2 changed files with 17 additions and 1 deletions

View File

@ -137,7 +137,8 @@ class ExecApiMixin(object):
data=data,
stream=True
)
if detach:
return self._result(res)
if socket:
return self._get_raw_response_socket(res)
return self._read_from_socket(res, stream)

View File

@ -93,6 +93,21 @@ class ExecTest(BaseAPIIntegrationTest):
data = read_exactly(socket, next_size)
self.assertEqual(data.decode('utf-8'), line)
def test_exec_start_detached(self):
container = self.client.create_container(BUSYBOX, 'cat',
detach=True, stdin_open=True)
container_id = container['Id']
self.client.start(container_id)
self.tmp_containers.append(container_id)
exec_id = self.client.exec_create(
container_id, ['printf', "asdqwe"])
self.assertIn('Id', exec_id)
response = self.client.exec_start(exec_id, detach=True)
self.assertEqual(response, "")
def test_exec_inspect(self):
container = self.client.create_container(BUSYBOX, 'cat',
detach=True, stdin_open=True)