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.

ContainerCreate fails with error #371

@logicminds

Description

@logicminds

I am trying to just create a simple container giving the API examples. I don't know enough about golang to troubleshoot this any further so I assume this might be a bug. I am able to list the containers correctly so at least I know talking to the API does work with GET

I inserted a Println statement in the assumed troubled code .

connection parameters

  endpoint := "unix:///var/run/docker.sock"
  defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"}

  cli, err := client.NewClient(endpoint, "v1.24", nil, defaultHeaders)

Creation code

r, err := cli.ContainerCreate(context.Background(), nil, nil, nil, "container_name")
  if err != nil {
    fmt.Println("error with creating:", err)
    panic(err)
  } else {
    fmt.Println(r)
  }

Output after panic (truncated) I have tried supplying full configs but have reduced to nil parameters for testing only. The tests themselves use the same procedure

// my println statement
path: /containers/create, query: map[name:[container_name]], obj: {%!s(*container.Config=<nil>) %!s(*container.HostConfig=<nil>) %!s(*network.NetworkingConfig=<nil>)}, headers: map[]


2016/08/16 22:33:14 [Recovery] panic recovered:
POST /session HTTP/1.1
Host: localhost:8080
Accept: */*
Content-Type: application/x-www-form-urlencoded
User-Agent: curl/7.43.0


runtime error: invalid memory address or nil pointer dereference
/usr/local/go/src/runtime/panic.go:443 (0x42e3b9)
    gopanic: reflectcall(nil, unsafe.Pointer(d.fn), deferArgs(d), uint32(d.siz), uint32(d.siz))
/usr/local/go/src/runtime/panic.go:62 (0x42ca75)
    panicmem: panic(memoryError)
/usr/local/go/src/runtime/sigpanic_unix.go:24 (0x442d1a)
    sigpanic: panicmem()
/go/src/github.com/docker/engine-api/client/client.go:106 (0x4e934e)
    (*Client).getAPIPath: if cli.version != "" {
/go/src/github.com/docker/engine-api/client/request.go:172 (0x5020ac)
    (*Client).newRequest: apiPath := cli.getAPIPath(path, query)
/go/src/github.com/docker/engine-api/client/request.go:91 (0x500ac8)
    (*Client).sendClientRequest: req, err := cli.newRequest(method, path, query, body, headers)
/go/src/github.com/docker/engine-api/client/request.go:77 (0x500780)
    (*Client).sendRequest: return cli.sendClientRequest(ctx, method, path, query, body, headers)
/go/src/github.com/docker/engine-api/client/request.go:40 (0x4ffe68)
    (*Client).post: return cli.sendRequest(ctx, "POST", path, query, obj, headers)
/go/src/github.com/docker/engine-api/client/container_create.go:35 (0x4ed01d)
    (*Client).ContainerCreate: serverResp, err := cli.post(ctx, "/containers/create", query, body, nil)
/go/src/gitlab.com/nwops/docker_proxy/main.go:234 (0x402105)
    create_container: r, err := cli.ContainerCreate(context.Background(), nil, nil, nil, "container_name")

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