You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Resource.Exec should wait for the command to finish before returning, otherwise the exit code it returns (which it gets from InspectExec) is always 0. Even for an extremely short-running command like false.
To Reproduce
Steps to reproduce the behavior:
package main
import (
"fmt""os""github.com/ory/dockertest/v3"
)
funcmain() {
pool, err:=dockertest.NewPool("")
iferr!=nil {
fmt.Println(fmt.Errorf("new pool failed: %v", err.Error()))
os.Exit(1)
}
resource, err:=pool.RunWithOptions(&dockertest.RunOptions{
Repository: "alpine",
Tag: "latest",
Cmd: []string{"sleep", "10"},
})
exitCode, err:=resource.Exec([]string{"false"}, dockertest.ExecOptions{})
iferr!=nil {
fmt.Println(fmt.Errorf("exec failed: %v", err.Error()))
os.Exit(1)
}
ifexitCode==0 {
fmt.Println("This should never happen! yet it does...")
os.Exit(1)
}
return
}
Expected behavior
I expect Exec to only return when the command is finished executing, and I expect the exit code returned by Exec to actually be the exit code of the command that finished and not always 0
- This bug was due to a bug in the vendored client library where
StartExec would return early even if opts.Detatch was true, if stderr
and stdout were not provided. This fix always attaches them and falls
back to io.Discard if the user does not provide their own readers.
- See: fsouza/go-dockerclient#838
- Fixesory#372
This bug was due to a bug in the vendored client library where
StartExec would return early even if opts.Detatch was true, if stderr
and stdout were not provided. This fix always attaches them and falls
back to io.Discard if the user does not provide their own readers.
See: fsouza/go-dockerclient#838Fixes#372
Describe the bug
Resource.Exec
should wait for the command to finish before returning, otherwise the exit code it returns (which it gets fromInspectExec
) is always0
. Even for an extremely short-running command likefalse
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expect Exec to only return when the command is finished executing, and I expect the exit code returned by Exec to actually be the exit code of the command that finished and not always 0
Environment
go.sum:
docker version
/etc/os-release
Additional context
As a workaround users can do something like this, for now, but it's very verbose & awkward:
The text was updated successfully, but these errors were encountered: