Unable to see docker-compose run output
Shell execution of
docker-compose run on Windows runners does not properly capture stdout.
Steps to reproduce
Place the attached
docker-compose.yml and the following
.gitlab-ci.yml config in a new repository and ensure a Windows runner (must be using the shell executor) processes the pipeline.
You can also use the attached
docker-compose.yml files to test the behavior directly on a Windows server with docker, docker-compose and Go installed.
- Place each file in the same directory
- Run the Go file:
go run test.go
compose: stage: build tags: - windows script: - docker-compose run --rm hello-world docker: stage: build tags: - windows script: - docker run --rm hello-world exec-go: stage: test tags: - windows script: cd src; go run test.go
The job executing
docker-compose run --rm hello-world does not show the hello-world image's output and completes successfully. However, the job executing
docker run --rm hello-world shows the hello-world image's output as intended before completing successfully.
If you execute each command directly within PowerShell (or CMD) on the runner itself the expected output can be seen. Attached are two screenshots - expected_output.png (taken from the
docker run job) and actual_output.png (taken from the
docker-compose run job).
I've written and attached a simple Go program (
test.go) that uses the same
os/exec package as the runner to execute commands directly on the host. This captures stdout and then writes it to the screen. Executing this on the host shows the same behavior that can be seen on the runner.
However, if you run the same program on a Linux machine you will find both commands show the full output from the hello-world image. The execution commands needs to be slightly adjusted for bash, so I have attached
It seems like Go may not be properly receiving/capturing the stdoutput from
docker-compose on Windows. If you execute the following PowerShell command on the Windows runner you'll see the redirected stdout properly populates the hello-world output in the
Start-Process -FilePath "docker-compose" -ArgumentList "run --rm hello-world" -RedirectStandardOutput "out.txt" -RedirectStandardError "error.txt"
I'm not sure if this is something we can work around within Go, or if the problem needs to be addressed upstream.
Output from the
docker-compose run command is successfully captured and seen when viewing the runner's job output.
Relevant logs and/or screenshots
This has been tested with Docker version 19.03.2. using a self-managed GitLab EE instance (12.2.4) and a self-managed runner.
concurrent = 1 check_interval = 0 [session_server] session_timeout = 1800 [[runners]] name = "winrunner" url = "https://gitlab.calebw.tech/" token = "" executor = "shell" shell = "powershell" [runners.custom_build_dir] [runners.cache] [runners.cache.s3] [runners.cache.gcs]
docker-compose version 1.24.1, build 4667896b