Closed pjh closed 2 months ago
I also looked through https://pkg.go.dev/github.com/docker/docker/client and https://github.com/moby/moby/tree/master/client for "stderr" but didn't see any obvious places to adjust this. But surely there must be a way, since the docker CLI also uses that library and results in the expected behavior. Right?
Nevermind 🤦 I didn't realize that the docker logs
command emits the container's stdout to stdout and the container's stderr to stderr, I thought everything just went to stdout where the command is run. After using dockertest I was only reading the stdout from a docker logs
command.
Preflight checklist
Ory Network Project
No response
Describe the bug
Containers started with dockertest do not correctly capture output written to stderr. Running
docker logs
against the container only shows output written to stdout, not to stderr. When the same container is started using the docker CLI, stderr is shown in thedocker logs
output as expected.I searched the dockertest package documentation and the code pretty thoroughly for mentions of
stderr
,stdout
etc. but I couldn't find any configurations to change that would affect this behavior.Reproducing the bug
See https://github.com/ory/dockertest/compare/v3...pjh:dockertest:demo-stderr for the code changes needed to reproduce this issue.
To observe the non-dockertest behavior, run:
docker buildx build . -t stderr
CONTAINER=$(docker run -d stderr:latest)
docker logs $CONTAINER
The output contains both stderr and stdout:
To observe the docketest behavior, run:
go test -C internal/pjh/ -v
The output contains stdout but not stderr:
Relevant log output
No response
Relevant configuration
No response
Version
github.com/ory/dockertest/v3 v3.11.0
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
No response