docker / docker/docker-py

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

Open
#3,329 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.