如何退出Docker远程API执行stream?

当我从Docker Remote API获取stream如下所示:

// 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\r\n")) conn.Write([]byte("Host:\r\n")) conn.Write([]byte("Connection: Upgrade\r\n")) conn.Write([]byte("Content-Type: application/json\r\n")) conn.Write([]byte("Upgrade: tcp\r\n")) conn.Write([]byte("Content-Length: " + fmt.Sprintf("%d", len(buf)) + "\r\n")) conn.Write([]byte("\r\n")) conn.Write(buf) return conn } 

之后,我断开连接,但是当我使用curl /exec/id/json来获得结果的状态时,sh仍然在运行。 所以我想知道closuressh的最好方法,即使在vi模式下也是如此。 谢谢 :)