compose: "docker-compose run -T" inconsistently outputs stdout / stderr?

I’ve noticed that docker-compose run -T seems to behave inconsistently from run to run with respect to outputting stderr and stdout.

For example, on repeated invocations of the following command:

$ docker-compose run -T web python3 -c "import sys; print(\"err\\n\", file=sys.stderr); print(\"stdout\\nstdout\\nstdout\\nstdout\\n\")"

the “err” usually doesn’t print out (but sometimes does), and the “stdout” messages usually (but don’t always) print.

This is a follow-up to issue #3239.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 22

Commits related to this issue

Most upvoted comments

We’ve run in, what seems like, the same issue with docker-compose 1.7.1, build 0a9ab35 on Mac OS X El Capitan - 10.11.5 (15F34).

When running a bash script inside the container, like such:

#!/usr/bin/env bash

for ((i=1; i<51; i++)); do
    echo "Line ${i}"
    sleep 0.1
done

a random amount of lines will be missing from stdout, when docker-compose is executed like such:

#!/usr/bin/env bash

sh -c "docker-compose run -T --rm test bash script.sh 1> stdout.log 2> stderr.log"

Both with and without the -T flag. When docker-compose is ran directly from terminal, it will only have partial output with the -T flag. When removing the sleep 0.1 from the bash script, it will always output all lines.

We’ve tested it with alpine:latest, debian:latest and debian:wheezy without any extras (except bash).

Using:

  • docker-machine version 0.7.0, build a650a40
  • Docker version 1.11.2, build b9f10c9
  • VirtualBox version 5.0.20 r106931

My 2 cents: I came across this issue while looking for a reason why when I run a docker-compose build --no-cache service > /dev/null it outputs Building service to stderr instead of stdout.

@shadiakiki1986 What you describe seems unrelated because this issue is about docker-compose run and you’re describing something about docker-compose build. Also, it seems like “Building service” should go to stderr rather than stdout since that is a progress message.

@shin- This particular problem no longer occurs for us when using Docker for Mac beta.