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
{{ message }}
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
Hello, I'm trying to run a command on a running container. I'm not sure what I'm doing wrong. Could you assist. Running the test below returns the following:
vagrant@vagrant-ubuntu-trusty-64:~/go/src/com.stuff/ambassador$ go test -test.run TestExec -v=== RUN TestExec
dac07107d20a5834826f16547945d5afe6b714fcefe0820fd64e5ea8b27b1aaf
--- PASS: TestExec (0.01s)
PASS
func TestExec(t *testing.T) {
//var sContainer dockerclient.Container
var config dockerclient.ExecConfig
containers, err := docker.ListContainers(true, false, "")
if err != nil {
t.Fatalf("cannot get containers: %s", err)
}
for _, c := range containers {
for _, name := range c.Names {
if name == "/testapi" {
config.Container = c.Id
}
}
}
if config.Container == "" {
t.Error("Container Not found")
}
config.Cmd = []string{"bash", "-c", "date"}
config.AttachStdout = true
config.AttachStderr = true
config.AttachStdin = false
config.Tty = false
config.Detach = false
ID, err := docker.ExecCreate(&config)
fmt.Println(ID)
if err != nil {
t.Error(err)
}
config.Cmd = []string{}
config.AttachStdout = true
config.AttachStderr = true
config.AttachStdin = true
config.Tty = true
config.Detach = true
//fmt.Print(config)
err = docker.ExecStart(ID, &config)
if err != nil {
t.Error(err)
}
//fmt.Print(containers)
}