When attaching to a container, I can attach to a container when I'm not using the TTY, however I use the TTY it doesn't return any data.
Here's the relevant code. If you uncomment the Tty line, at least for me, it exhibits the behaviour. If its commented out, everything works fine.
cfg := &container.Config{
AttachStdin: false,
AttachStdout: true,
AttachStderr: true,
Image: <image name>,
Labels: map[string]string{},
//Tty: true,
}
hostCfg := &container.HostConfig{}
netCfg := &network.NetworkingConfig{
EndpointsConfig: map[string]*network.EndpointSettings{},
}
resp, err := client.ContainerCreate(cfg, hostCfg, netCfg, <image name>)
if err != nil {
log.Fatalf("Couldn't create container '%s': %s", <image name>, err)
}
cId := resp.ID
aResp, err := client.ContainerAttach(types.ContainerAttachOptions{
ContainerID: cId,
Stream: true,
Stdin: false,
Stdout: true,
Stderr: true,
})
if err != nil {
log.Fatalf("Couldn't attach to container: %s", err)
}
if err = client.ContainerStart(cId); err != nil {
log.Error("There was a problem running the container")
return 1, err
}
go func() {
defer aResp.Close()
stdcopy.StdCopy(os.Stdout, os.Stderr, aResp.Reader)
}()
rc, err := client.ContainerWait(cId)
if err != nil {
log.Errorf("Error waiting for container to finished: %s", err)
return rc, err
}