docker / docker/docker-py

Several questions about container.logs / certain container hangs

Open
#1,729 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

I have several questions about container.logs. I'm using Python 3 with docker-py 2.5.1.

  • What's the difference between stream and follow? It looks like if I specify stream, it will wait for more logs to come, which is essentially follow. On the other hand, if I specify follow, then it has to be stream (how else will I get results?)
  • What's the return type. In the docs it says that string is returned if not streaming. However, I'm getting bytes. I am getting strings (in the generator) when streaming at some time - I haven't been able to identify when it returns string vs. bytes, but I seem to be getting strings in a ThreadPoolExecutor environment, and bytes if it's in its dedicated process.

Also, I can't get streaming logs for certain containers, consistently, at least if I start the stream as soon as the container is started. There's no error, but it simply hangs forever. (It take the container say 5 minutes to produce the first line) But there is log, and I can get it after it's produced. Unfortunately I'm not able to reproduce with trivial examples.

Any help is much appreciated. Thanks!

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 with the container.logs entry point and the Python 3/docker-py 2.5.1 behavior described here. Compare stream and follow semantics, record whether non-streaming and streaming results are bytes or strings, and investigate the reported hang when streaming starts immediately after container startup. Done means the behavior is reproducible or explained, with the expected return types and option semantics made clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
api
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.