docker / docker/docker-py

how to get STDOUT when the container exit with non-zero code?

Open
#2,745 1 comment 1 reaction 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 run a command in a container with containers.run() method, when an error happened, the container returns a non-zero code, then I can only see the contents og STDERR in ContainerError.

If I correctly understood the codes, when a container exit with non-zero code, it firstly clean the out variable, and collect all STDERR and pass it to ContainerError object.
image

I would like to see the STDOUT messages before the error happened, is there a way to do that?

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 from the containers.run() call and the ContainerError behavior described in the issue, then reproduce a non-zero exit with output on both streams. Check whether stdout is discarded before the error is raised. Done means callers can access the stdout produced before failure while still receiving the non-zero exit error 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.