Skip to content

client.containers.run(...) gives different output than docker run CLI for local docker images #3329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
nkuehnle opened this issue Apr 17, 2025 · 0 comments

Comments

@nkuehnle
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant