Default value of follow is not false when calling container.logs()
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
This came up in a stack overflow question, and I thought I would open an issue here as I think it is either a bug or maybe the docs just need to be updated, not sure.
Consider this example code that iterates through 3 containers and writes out their logs using streams:
import docker
client = docker.from_env()
container_names = ['container1','container2','container3']
for container_name in container_names:
dkg = client.containers.get(container_name).logs(stream = True)
try:
while True:
line = next(dkg).decode("utf-8")
print(line)
except StopIteration:
print(f'log stream ended for {container_name}')
It blocks while reading the first containers logs.
But if I change this line:
dkg = client.containers.get(container_name).logs(stream = True)
to this:
dkg = client.containers.get(container_name).logs(stream = True, follow = False)
It no longer blocks and outputs the logs for all three containers.
The docs say the default value for follow is False, but that doesn't seem to be the case, given the above example.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docker/api/container.py at the documented logs entry point and reproduce the supplied loop with stream=True, then compare it with the explicit follow=False call. Check the related tests or request construction to determine whether the behavior or documentation is wrong; done means the default behavior matches the documented value or the documentation accurately explains it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100