`exec_run` with `demux=True`: output is `None` instead of empty `bytes`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
When calling exec_run with demux=True, the documentation states that a pair of bytes is returned.
However, if no standard output (or no standard error) is produced, then the corresponding tuple entry is None instead of an empty bytes (b'').
Minimum working example:
import docker
client = docker.from_env()
container = client.containers.run("alpine:latest", detach=True, tty=True)
container.exec_run(("sh", "-c", "echo out >&1"), demux=True) # ExecResult(exit_code=0, output=(b'out\n', None))
container.exec_run(("sh", "-c", "echo err >&2"), demux=True) # ExecResult(exit_code=0, output=(None, b'err\n'))
The expected behaviour is that both tuple entries are always bytes. Alternatively, the possibility of returning None should be documented clearly!
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 the exec_run entry point and run the minimum working example against alpine:latest with demux=True to reproduce both output cases. Done means the behavior matches the expected pair of bytes, or the documentation clearly explains when a tuple entry is None; add coverage for the no-stdout and no-stderr cases if the existing test suite has a relevant location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100