client.containers.run(...) gives different output than docker run CLI for local docker images
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
I'm trying to figure out why my custom image gives different behavior even for a simple echo hello world command, this behavior isn't observed for a base alpine image alone. I'm pretty confused why this would be the case. The python environment this is running from is the same environment/shell that is used to launch the cli commands on the same local system.
client = docker.from_env()
container = client.containers.run(
image='test_img',
command="echo hello world",
remove=True,
stdout=True,
stderr=True,
)
container
b'\n'
docker run test_img "echo hello world"
hello world
client = docker.from_env()
container = client.containers.run(
image='alpine',
command="echo hello world",
remove=True,
stdout=True,
stderr=True,
)
container
b'hello world\n'
docker run alpine "echo hello world"
hello world
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 by reproducing the two client.containers.run(...) and docker run commands shown in the issue, comparing the custom test_img with alpine. Read the client.containers.run entry point and the Docker Engine API behavior for image commands and output capture. Done means identifying why the custom image differs and documenting or correcting the behavior so the expected output is consistent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100