Reputation: 348
I have the following Go code, where I try to spawn docker
command and get its output:
package main
import "fmt"
import "os/exec"
func main() {
cmd := exec.Command("docker")
cmdOutput, err := cmd.Output()
if (err != nil) {
panic(err)
}
fmt.Println(string(cmdOutput))
}
But when I run this code as a result I get an empty string, which is stange since I get an output when I run docker
command directly in a command line.
Moreover, this same code yields results just fine if I spawn other commands with it, for example ls
.
What may be wrong here?
Upvotes: 0
Views: 78