Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Hijack is incompatible with use of CloseNotifier #303

@raphink

Description

@raphink

This is caused by moby/moby#12845

package main

import (
  "fmt"
  "io/ioutil"

  "github.com/docker/engine-api/client"
  "github.com/docker/engine-api/types"
  "golang.org/x/net/context"
)

// Some basic nginx container running
const ContainerID string = "ce5d8b318ca0"

func main() {
  c, _ := client.NewClient("unix:///var/run/docker.sock", "", nil, nil)

  body, _ := c.ContainerLogs(context.Background(), ContainerID, types.ContainerLogsOptions{
    ShowStdout: true,
    ShowStderr: true,
  })

  defer body.Close()

  // This line causes ContainerExecStart to fail with
  // Error response from daemon: http: Hijack is incompatible with use of CloseNotifier
  _, _ = ioutil.ReadAll(body)

  exec, _ := c.ContainerExecCreate(context.Background(), ContainerID, types.ExecConfig{
    Cmd: []string{"date"},
  })

  err := c.ContainerExecStart(context.Background(), exec.ID, types.ExecStartCheck{})
  fmt.Println(err)
}
$ go run engine-api-bug.go 
Error response from daemon: http: Hijack is incompatible with use of CloseNotifier

How can I fix this with engine-api?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions