Skip to content

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

Open
@nkuehnle

Description

@nkuehnle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions