-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forward STDOUT/STDERR #42
Comments
Hi @alixaxel There is not an option for this at the moment, but there should be! I'll add this in for the next release. |
@andystanton Thanks for getting back to me. Yeah, I think that this feature is a important one to have. If I use the following code as it's being used by package main
import (
"os"
"os/exec"
)
func main() {
cmd := exec.Command("node", "/home/alix/streams.js")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Run()
} So my assumption is that Docker itself is not forwarding the streams properly. |
I found this old related issue (moby/moby#725), but it was fixed a long time ago. So I did a couple of tests running the Docker container directly: alix@900X4C:~/$ docker run --rm -v $(pwd -P)/streams.js:/tmp/dexec/build/streams.js -t dexec/lang-node streams.js
stdout
stderr
alix@900X4C:~/$ docker run --rm -v $(pwd -P)/streams.js:/tmp/dexec/build/streams.js -t dexec/lang-node streams.js 1>/dev/null
alix@900X4C:~/$ docker run --rm -v $(pwd -P)/streams.js:/tmp/dexec/build/streams.js -t dexec/lang-node streams.js 2>/dev/null
stdout
stderr Same behavior. However, if you remove the alix@900X4C:~/$ docker run --rm -v $(pwd -P)/streams.js:/tmp/dexec/build/streams.js dexec/lang-node streams.js
stderr
stdout
alix@900X4C:~/$ docker run --rm -v $(pwd -P)/streams.js:/tmp/dexec/build/streams.js dexec/lang-node streams.js 1>/dev/null
stderr
alix@900X4C:~/$ docker run --rm -v $(pwd -P)/streams.js:/tmp/dexec/build/streams.js dexec/lang-node streams.js 2>/dev/null
stdout It works out nicely. The flag
Would you accept a PR that removes it or is this critical for something else? |
forward stderr/stdout for issue #42
Thanks for the fix @alixaxel I've accepted the PR and will make a 1.0.3 patch release containing this fix. Ultimately I want to move away from shelling out commands to the Docker CLI. I created #35 to address this and have done some work, but I think a better approach would be to make dexec use one of the existing Go libraries: https://docs.docker.com/engine/reference/api/remote_api_client_libraries/ |
With a simple PHP script that writes to both
STDOUT
andSTDERR
:The output streams work as expected when executed with PHP directly:
However, when running via dexec,
STDERR
is treated as if it wasSTDOUT
:The exact same thing happens with a Node.js script:
Is there any option to make
dexec
respect and forwardSTDOUT
andSTDERR
?The text was updated successfully, but these errors were encountered: