docker / docker/docker-py

container.logs(stream=True) delayed

Open
#2,561 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
7.2k
Forks
1.7k
Avg merge
13d 8h
Merged PRs (30d)
2

Description

docker-py: 4.2.0
OS: Windows 10
Docker: 2.3.0.2
Engine: 19.03.8

I have a simple code to read a stream of logs from a specific container. I am setting stream=True to continuously read new logs as they're logged. However, it appears that the SDK receives (or prints) logs with a "delay".

If the stream of logs in the monitored container is regular and continuous, the monitoring container with python SDK running prints new logs every ~5 seconds. When monitoring other containers that write into stdout rarely, it appears that the container.logs function waits for a certain volume of logs to be collected before releasing the next logs entry.

for log in container.logs(stream=True, stdout=True, stderr=True):
    print(log)

I would like to know why I'm seeing a delay in the logs stream, and whether I can change it via configuration.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the delay with container.logs(stream=True, stdout=True, stderr=True) using both continuously writing and rarely writing containers. Start by determining whether buffering occurs in the Python SDK or the Docker Engine API. Done means explaining the source of the delay and identifying whether a configuration can change it.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.