No stdout from docker.container.run even with stderr and stdout set to True
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
When I run my docker image normally like so
docker run -v ..... {DOCKER_IMAGE}
I get my log/stdout in the terminal as expected. But running like so:
docker_client = docker.from_env() docker_client.containers.run(DOCKER_IMAGE, None, environment=[f'foo={self.profile}'], volumes={...,}, auto_remove=True, stderr=True, stdout=True) # No stdout
Seems to suppress output. How can I get the log output while it's running? Can I stream the docker container run?
Right now I'm doing this:
docker_client.containers.run(DOCKER_IMAGE, None, environment=[f'foo={self.profile}'], volumes={...,}, auto_remove=True, stderr=True, stdout=True, detach=True)
for line in container.logs(stream=True):
logger.info(line.strip().decode('utf8'))
But the problem is that this removes stdout and stderr, it'll all just be info.
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 Python API entry points shown in the report: docker.from_env(), containers.run(), and container.logs(stream=True). Compare the behavior of attached and detached runs, including stderr=True and stdout=True. Done means container output can be streamed while retaining the distinction between stdout and stderr.
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
- 35/100