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

时间:2016-10-11 07:15:01

标签: go docker

当我从Docker Remote API获得这样的流:

// 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仍在运行。所以我想知道关闭sh的最佳方法,即使在vi模式下也是如此。 thx:)

0 个答案:

没有答案