Visitar URL original
Hijack is incompatible with use of CloseNotifier · Issue #303 · docker-archive-public/docker.engine-api · GitHub
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

Open

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?

Activity

  1. cpuguy83 commented on Jul 5, 2016

    @cpuguy83
    Contributor

    This is likely from connection re-use, which is automatic from the http package.

    In the client transport we'll either need to set DisableKeepAlives or maybe in ContainerExecStart we can make sure to set Close in the request?

  2. raphink commented on Jul 5, 2016

    @raphink
    Author

    This should work. Currently, I have to create a new Docker client for the ContainerExecStart.

  3. cpuguy83 commented on Jul 5, 2016

    @cpuguy83
    Contributor

    This could probably be considered a golang bug. We should not have to manually manage this when the http package knows we've hijacked the connection.

  4. LK4D4 commented on Jul 5, 2016

    @LK4D4
    Contributor

    I belive fix for this was on go1.6
    golang/go@99fb191

  5. cpuguy83 commented on Jul 5, 2016

    @cpuguy83
    Contributor

    It would seem so.
    @raphink any chance you can test with go 1.6?

  6. raphink commented on Jul 5, 2016

    @raphink
    Author

    I get this bug with all versions of go, including tip. I think it's the docker engine that needs to be rebuilt with the new version of go.

  7. thaJeztah commented on Jul 5, 2016

    @thaJeztah
    Contributor

    @cpuguy83 @LK4D4 saw that someone reported this issue on 1.12-rc3 (which uses go 1.6); moby/moby#12845 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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