docker / docker/docker-py

Docker Logs Stream

Open
#2,984 1 comment 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

I want to stream a running containers stdout logs to my interpreter however the logs don't appear when the container is running. When the container finishes all the logs are printed at once. Any ideas where I can start to troubleshoot this issue? I’m using dockerpy 5.0.3 and Docker Desktop 4.7.1. Thank you in advance.

client = docker.from_env()
container = client.containers.run(
"ptcloud2ptcloud:latest",
command=["/bin/bash", "-c", cmd],
volumes=volumes,
detach=True,
remove=True,
stdout=True,
stderr=True,
cpu_count=7,
mem_limit='16g',

)

print("container submitted")
for line in container.logs(stream=True):
print(line.strip())

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

Start by reproducing the behavior with the Python example and its container.logs(stream=True) loop, checking output while the container is still running and after it exits. Determine whether the missing live output is caused by the client, Docker Engine behavior, or buffering in the shown command, then document a reproducible cause and expected streaming behavior.

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
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.