Skip to content

Demux stdout and stderr from result of attach() command #1952

@sanathkr

Description

@sanathkr

When I run container.attach(stdout=True, stderr=True, stream=True, logs=True), the resulting generator contains the output of stdout and stderr multiplexed into one string. I would like to separate to get stdout and stderr in separate generators (or) streams.

I know the Go SDK contains a stdcopy.StdCopy precisely for the purpose of demuxing the output given a raw socket. I would like to implement something similar for the Docker Python SDK as well.

I need this for my project, so I am going to implement anyway, but would you be open to the idea of my contributing the patch back to this project? Actually most of the functionality is already implemented in socket.py. Instead of discarding the frame type, I will pass it out and have the caller decide how to handle it. The attach() method will discard the type, whereas, a new docker.util.demuxSocketOutput(stdout_stream, stderr_stream) will write the output to respective the streams.

Would you be open to this idea? I send a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions