Unverified Kaydet (Commit) 228764ac authored tarafından Joffrey F's avatar Joffrey F Kaydeden (comit) GitHub

Merge pull request #1840 from docker/1813-autoremove-error

Don't attempt to retrieve container's stderr if `auto_remove` was set
......@@ -737,7 +737,9 @@ class ContainerCollection(Collection):
exit_status = container.wait()
if exit_status != 0:
out = container.logs(stdout=False, stderr=True)
out = None
if not kwargs.get('auto_remove'):
out = container.logs(stdout=False, stderr=True)
if remove:
container.remove()
......
import docker
import tempfile
import docker
import pytest
from .base import BaseIntegrationTest, TEST_API_VERSION
from ..helpers import random_name, requires_api_version
......@@ -114,6 +116,16 @@ class ContainerCollectionTest(BaseIntegrationTest):
)
assert out == b'hello\n'
@requires_api_version('1.25')
def test_run_with_auto_remove_error(self):
client = docker.from_env(version=TEST_API_VERSION)
with pytest.raises(docker.errors.ContainerError) as e:
client.containers.run(
'alpine', 'sh -c ">&2 echo error && exit 1"', auto_remove=True
)
assert e.value.exit_status == 1
assert e.value.stderr is None
def test_run_with_streamed_logs(self):
client = docker.from_env(version=TEST_API_VERSION)
out = client.containers.run(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment