docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

Output ignored after last newline character

Open LoicGombeaud opened this issue 2 years ago • 0 comments

Hello, it seems that any output from the container after the last newline character is ignored; for instance, if I run:

import docker

client = docker.from_env()

hello_world = client.containers.run('alpine',
                                    'echo Hello world',  # Ends with a newline
                                     auto_remove=True)
print(hello_world)

hello_again = client.containers.run('alpine',
                                    'echo -n Hello again',  # Doesn't end with a newline
                                     auto_remove=True)
print(hello_again)

Then the output is:

b'Hello world\n'
b''

It seems to be a bug, especially since in the first case, the newline is included in the output; can you please look into it?

LoicGombeaud avatar Mar 03 '22 16:03 LoicGombeaud