When I get a stream from Docker Remote API like this:
// Exec exec command
func (d *Docker) ExecStart(host, id string) (net.Conn) {
config := map[string]interface{}{
"Detach": false,
"Tty": true,
}
buf, _ := json.Marshal(config)
conn, _ := net.Dial("tcp", host)
conn.Write([]byte("POST /exec/" + id + "/start HTTP/1.1
"))
conn.Write([]byte("Host:
"))
conn.Write([]byte("Connection: Upgrade
"))
conn.Write([]byte("Content-Type: application/json
"))
conn.Write([]byte("Upgrade: tcp
"))
conn.Write([]byte("Content-Length: " + fmt.Sprintf("%d", len(buf)) + "
"))
conn.Write([]byte("
"))
conn.Write(buf)
return conn
}
After that, I disconnect the conn, but when I use curl /exec/id/json
to get the status of result, the sh still running. So I want to know the best way to close the sh, even in vi
mode. thx :)