Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions docker/models/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,9 +829,10 @@ def run(self, image, command=None, stdout=True, stderr=False,
The container logs, either ``STDOUT``, ``STDERR``, or both,
depending on the value of the ``stdout`` and ``stderr`` arguments.

``STDOUT`` and ``STDERR`` may be read only if either ``json-file``
or ``journald`` logging driver used. Thus, if you are using none of
these drivers, a ``None`` object is returned instead. See the
``STDOUT`` and ``STDERR`` may be read only if a ``json-file``,
``journald``, or ``local`` logging driver is used. Thus, if you
are using none of these drivers, a ``None`` object is returned
instead. See the
`Engine API documentation
<https://docs.docker.com/engine/api/v1.30/#operation/ContainerLogs/>`_
for full details.
Expand Down Expand Up @@ -889,7 +890,7 @@ def run(self, image, command=None, stdout=True, stderr=False,
logging_driver = container.attrs['HostConfig']['LogConfig']['Type']

out = None
if logging_driver == 'json-file' or logging_driver == 'journald':
if logging_driver in ('json-file', 'journald', 'local'):
out = container.logs(
stdout=stdout, stderr=stderr, stream=True, follow=True
)
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/models_containers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ def test_run(self):
follow=True
)

def test_run_local_logging_driver(self):
client = make_fake_client()
inspected = client.api.inspect_container.return_value
inspected['HostConfig']['LogConfig']['Type'] = 'local'

out = client.containers.run("alpine", "echo hello world")

assert out == b'hello world\n'
client.api.logs.assert_called_with(
FAKE_CONTAINER_ID, stderr=False, stdout=True, stream=True,
follow=True
)

def test_create_container_args(self):
networking_config = {
'foo': EndpointConfig(
Expand Down