Skip to content

POST requests to start endpoint fails with ContentLength error #33501

@FrenchBen

Description

@FrenchBen

Description

Making an API request to start a container with an empty JSON string in the body will return the following error:
{"message":"starting container with non-empty request body was deprecated since v1.10 and removed in v1.12"}

This functionality worked in all previous versions of docker but is now broken in 17.06.0-rc1

Steps to reproduce the issue:

  1. Create a container
  2. Send a request to start the container via the API and an empty JSON string {}
  3. Get the above error
$ docker create --name my-test alpine top
$ curl -vvv --unix-socket /var/run/docker.sock -X POST -H 'Content-Type: application/json' -d '{}' http://1.29/containers/my-test/start
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying /var/run/docker.sock...
...
> POST /containers/my-test/start HTTP/1.1
> Host: 1.29
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 2
>
* upload completely sent off: 2 out of 2 bytes
< HTTP/1.1 400 Bad Request
< Api-Version: 1.30
< Content-Length: 109
< Content-Type: application/json
< Date: Fri, 02 Jun 2017 21:57:20 GMT
< Docker-Experimental: true
< Ostype: linux
< Server: Docker/17.06.0-ce-rc1 (linux)
<
{"message":"starting container with non-empty request body was deprecated since v1.10 and removed in v1.12"}
* Curl_http_done: called premature == 0
* Connection #0 to host 1.29 left intact

To make it work:

$ curl --unix-socket /var/run/docker.sock -X POST -H 'Content-Type: application/json' -d '' http://1.29/containers/my-test/start

Describe the results you received:
{"message":"starting container with non-empty request body was deprecated since v1.10 and removed in v1.12"}

Describe the results you expected:
For the container to start

Additional information you deem important (e.g. issue happens only occasionally):
https://github.com/moby/moby/blob/master/api/server/router/container/container_routes.go#L144

Output of docker version:

Client:
 Version:      17.06.0-ce-rc1
 API version:  1.30
 Go version:   go1.8.1
 Git commit:   7f8486a
 Built:        Wed May 31 02:56:01 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.06.0-ce-rc1
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.1
 Git commit:   7f8486a
 Built:        Wed May 31 03:00:14 2017
 OS/Arch:      linux/amd64
 Experimental: true

Additional environment details (AWS, VirtualBox, physical, etc.):
Version 17.06.0-rc1-ce-mac13 (18169)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/apiAPIkind/bugBugs are bugs. The cause may or may not be known at triage time so debugging may be needed.platform/macpriority/P1Important: P1 issues are a top priority and a must-have for the next release.version/17.06

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions