**kwargs
just means the parameters listed are "keyword arguments", so for the attach
function, it takes in these parameters (or "arguments") in any order using the form keyword=value
:
stdout
(bool) – Include stdout.
stderr
(bool) – Include stderr.
stream
(bool) – Return container output progressively as an iterator
of strings, rather than a single string.
logs
(bool) – Include the container’s previous output.
To call this function, you would do:
logs = container.attach(stdout=True, stderr=True, stream=True, logs=True)
Note that the documentation also states the logs
function is a wrapper around the attach
function, so you could use that function instead of attach
.
Edit:
Complete usage example:
import docker
client = docker.from_env()
container = client.containers.run('hello-world', detach=True)
# method 1
print(container.logs())
# method 2
logs = container.attach(stdout=True, stderr=True, stream=False, logs=True)
print(logs)