Skip to content

start container request fails for OSX daemon#856

Closed
tolkonepiu wants to merge 1 commit intodocker-java:masterfrom
tolkonepiu:fix_start_container_request
Closed

start container request fails for OSX daemon#856
tolkonepiu wants to merge 1 commit intodocker-java:masterfrom
tolkonepiu:fix_start_container_request

Conversation

@tolkonepiu
Copy link
Copy Markdown

@tolkonepiu tolkonepiu commented Jun 5, 2017

Fix bad request when StartContainerCmd doing POST request with non-empty body.

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

Exception:

com.github.dockerjava.api.exception.BadRequestException: {"message":"starting container with non-empty request body was deprecated since v1.10 and removed in v1.12"}

This change is Reviewable

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #856 into master will increase coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #856      +/-   ##
==========================================
+ Coverage   71.53%   71.65%   +0.12%     
==========================================
  Files         306      306              
  Lines        6665     6665              
  Branches      501      501              
==========================================
+ Hits         4768     4776       +8     
+ Misses       1603     1598       -5     
+ Partials      294      291       -3
Impacted Files Coverage Δ
...b/dockerjava/netty/exec/StartContainerCmdExec.java 100% <ø> (ø) ⬆️
...ava/netty/handler/FramedResponseStreamHandler.java 93.1% <0%> (+3.44%) ⬆️
...va/org/apache/http/impl/io/ChunkedInputStream.java 61.16% <0%> (+5.82%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f71887...aabe93d. Read the comment docs.

@KostyaSha
Copy link
Copy Markdown
Member

There is integration tests that working fine, this issue was fixed long time ago. I don't know how you get this issue.

@tolkonepiu
Copy link
Copy Markdown
Author

Im updated the docker on Mac to version 17.06.0-rc1-ce-mac13 (18169) and get this issue.

@KostyaSha
Copy link
Copy Markdown
Member

Have you tried dump traffic? Does it have non empty body?

@tolkonepiu
Copy link
Copy Markdown
Author

After changes? I run curl on my docker with non-empty body:

curl -v -X POST -d "437fbb337499" --unix-socket /var/run/docker.sock localhost:59222/v1.30/containers/437fbb337499/start
*   Trying /var/run/docker.sock...
> POST /v1.30/containers/437fbb337499/start HTTP/1.1
> Host: localhost:59222
> User-Agent: curl/7.51.0
> Accept: */*
> Content-Length: 12
> Content-Type: application/x-www-form-urlencoded

< HTTP/1.1 400 Bad Request
< Api-Version: 1.30
< Content-Length: 109
< Content-Type: application/json
< Date: Mon, 05 Jun 2017 16:00:21 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"}

And with empty body:

curl -v -X POST --unix-socket /var/run/docker.sock localhost:59222/v1.30/containers/437fbb337499/start
*   Trying /var/run/docker.sock...
> POST /v1.30/containers/437fbb337499/start HTTP/1.1
> Host: localhost:59222
> User-Agent: curl/7.51.0
> Accept: */*

< HTTP/1.1 204 No Content
< Api-Version: 1.30
< Date: Mon, 05 Jun 2017 16:08:11 GMT
< Docker-Experimental: true
< Ostype: linux
< Server: Docker/17.06.0-ce-rc1 (linux)

@KostyaSha
Copy link
Copy Markdown
Member

Not curl, wireshark/tcpdump traffic between docker-java and daemon.

@KostyaSha
Copy link
Copy Markdown
Member

@tolkonepiu
Copy link
Copy Markdown
Author

wireshark/tcpdump on unix socket? Are you sure about it?

@KostyaSha
Copy link
Copy Markdown
Member

Nobody enforce to use unix socket, request json shouldn't differ for socket vs rest connection.

@tolkonepiu
Copy link
Copy Markdown
Author

@KostyaSha
Copy link
Copy Markdown
Member

That's jersey, your change is for netty. When i were testing this issue netty has no problems. Could you list classpath libraries with versions?

@KostyaSha
Copy link
Copy Markdown
Member

KostyaSha commented Jun 5, 2017

{"message":"starting container with non-empty request body was deprecated since v1.10 and removed in v1.12"}
=== {} and != null AFAIR, but i firstly would like to see what is in real request that causing this error. And btw docker had some my fixes for this error message.

@tolkonepiu
Copy link
Copy Markdown
Author

tolkonepiu commented Jun 5, 2017

Nope.

curl -v -X POST -d '{}' -H 'Content-Type: application/json' --unix-socket /var/run/docker.sock localhost:59222/v1.30/containers/437fbb337499/start
*   Trying /var/run/docker.sock...
> POST /v1.30/containers/437fbb337499/start HTTP/1.1
> Host: localhost:59222
> 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: Mon, 05 Jun 2017 16:30:54 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"}

@tolkonepiu
Copy link
Copy Markdown
Author

i firstly would like to see what is in real request that causing this error. And btw docker had some my fixes for this error message.

Ok. Im trying use socat.

@KostyaSha
Copy link
Copy Markdown
Member

@tolkonepiu
Copy link
Copy Markdown
Author

I created container and started it on docker-java 3.0.9.

socat -v UNIX-LISTEN:/tmp/fake,fork UNIX-CONNECT:/var/run/docker.sock
> 2017/06/05 20:04:27.800034  length=78 from=0 to=77
GET /_ping HTTP/1.1\r
host: \r
connection: keep-alive\r
accept-encoding: gzip\r
\r
< 2017/06/05 20:04:27.807806  length=218 from=0 to=217
HTTP/1.1 200 OK\r
Api-Version: 1.30\r
Content-Length: 2\r
Content-Type: text/plain; charset=utf-8\r
Date: Mon, 05 Jun 2017 17:04:27 GMT\r
Docker-Experimental: true\r
Ostype: linux\r
Server: Docker/17.06.0-ce-rc1 (linux)\r
\r
OK> 2017/06/05 20:04:28.263605  length=77 from=0 to=76
GET /info HTTP/1.1\r
host: \r
connection: keep-alive\r
accept-encoding: gzip\r
\r
< 2017/06/05 20:04:28.297726  length=216 from=0 to=215
HTTP/1.1 200 OK\r
Api-Version: 1.30\r
Content-Type: application/json\r
Date: Mon, 05 Jun 2017 17:04:28 GMT\r
Docker-Experimental: true\r
Ostype: linux\r
Server: Docker/17.06.0-ce-rc1 (linux)\r
Transfer-Encoding: chunked\r
\r
< 2017/06/05 20:04:28.298114  length=2196 from=216 to=2411
888\r
{"ID":"SGDK:XFT7:BI7K:6IAI:FQID:ZWHH:266S:PR4L:WYFJ:SEL2:5TDH:JXCB","Containers":9,"ContainersRunning":0,"ContainersPaused":0,"ContainersStopped":9,"Images":49,"Driver":"aufs","DriverStatus":[["Root Dir","/var/lib/docker/aufs"],["Backing Filesystem","extfs"],["Dirs","182"],["Dirperm1 Supported","true"]],"SystemStatus":null,"Plugins":{"Volume":["local"],"Network":["bridge","host","ipvlan","macvlan","null","overlay"],"Authorization":null,"Log":["awslogs","fluentd","gcplogs","gelf","journald","json-file","logentries","splunk","syslog"]},"MemoryLimit":true,"SwapLimit":true,"KernelMemory":true,"CpuCfsPeriod":true,"CpuCfsQuota":true,"CPUShares":true,"CPUSet":true,"IPv4Forwarding":true,"BridgeNfIptables":true,"BridgeNfIp6tables":true,"Debug":true,"NFd":18,"OomKillDisable":true,"NGoroutines":30,"SystemTime":"2017-06-05T17:04:28.285989377Z","LoggingDriver":"json-file","CgroupDriver":"cgroupfs","NEventsListener":1,"KernelVersion":"4.9.30-moby","OperatingSystem":"Alpine Linux v3.5","OSType":"linux","Architecture":"x86_64","IndexServerAddress":"https://index.docker.io/v1/","RegistryConfig":{"AllowNondistributableArtifactsCIDRs":[],"AllowNondistributableArtifactsHostnames":[],"InsecureRegistryCIDRs":["127.0.0.0/8"],"IndexConfigs":{"docker.io":{"Name":"docker.io","Mirrors":[],"Secure":true,"Official":true}},"Mirrors":[]},"NCPU":2,"MemTotal":2096177152,"DockerRootDir":"/var/lib/docker","HttpProxy":"","HttpsProxy":"","NoProxy":"*.local, 169.254/16","Name":"moby","Labels":null,"ExperimentalBuild":true,"ServerVersion":"17.06.0-ce-rc1","ClusterStore":"","ClusterAdvertise":"","Runtimes":{"runc":{"path":"docker-runc"}},"DefaultRuntime":"runc","Swarm":{"NodeID":"","NodeAddr":"","LocalNodeState":"inactive","ControlAvailable":false,"Error":"","RemoteManagers":null},"LiveRestoreEnabled":false,"Isolation":"","InitBinary":"docker-init","ContainerdCommit":{"ID":"3addd840653146c90a254301d6c3a663c7fd6429","Expected":"3addd840653146c90a254301d6c3a663c7fd6429"},"RuncCommit":{"ID":"992a5be178a62e026f4069f443c6164912adbf09","Expected":"992a5be178a62e026f4069f443c6164912adbf09"},"InitCommit":{"ID":"949e6fa","Expected":"949e6fa"},"SecurityOptions":["name=seccomp,profile=default"]}
\r
0\r
\r
> 2017/06/05 20:04:28.438162  length=106 from=0 to=105
GET /version HTTP/1.1\r
host: \r
connection: keep-alive\r
accept-encoding: gzip\r
accept: application/json\r
\r
< 2017/06/05 20:04:28.440703  length=209 from=0 to=208
HTTP/1.1 200 OK\r
Api-Version: 1.30\r
Content-Length: 244\r
Content-Type: application/json\r
Date: Mon, 05 Jun 2017 17:04:28 GMT\r
Docker-Experimental: true\r
Ostype: linux\r
Server: Docker/17.06.0-ce-rc1 (linux)\r
\r
< 2017/06/05 20:04:28.441142  length=244 from=209 to=452
{"Version":"17.06.0-ce-rc1","ApiVersion":"1.30","MinAPIVersion":"1.12","GitCommit":"7f8486a","GoVersion":"go1.8.1","Os":"linux","Arch":"amd64","KernelVersion":"4.9.30-moby","Experimental":true,"BuildTime":"2017-05-31T03:00:14.205343778+00:00"}
> 2017/06/05 20:04:28.491495  length=128 from=0 to=127
GET /images/json?filter=alpine:3.2 HTTP/1.1\r
host: \r
connection: keep-alive\r
accept-encoding: gzip\r
accept: application/json\r
\r
< 2017/06/05 20:04:28.515292  length=209 from=0 to=208
HTTP/1.1 200 OK\r
Api-Version: 1.30\r
Content-Length: 244\r
Content-Type: application/json\r
Date: Mon, 05 Jun 2017 17:04:28 GMT\r
Docker-Experimental: true\r
Ostype: linux\r
Server: Docker/17.06.0-ce-rc1 (linux)\r
\r
< 2017/06/05 20:04:28.515750  length=244 from=209 to=452
[{"Containers":-1,"Created":1494434174,"Id":"sha256:87ab25c5a2f0446d975d3d599902fd207e511138e5918db6102e7249f684b21e","Labels":{},"ParentId":"","RepoDigests":null,"RepoTags":["alpine:3.2"],"SharedSize":-1,"Size":5264773,"VirtualSize":5264773}]
^[[19~> 2017/06/05 20:24:55.243104  length=256 from=0 to=255
POST /containers/create HTTP/1.1\r
content-type: application/json\r
content-length: 87\r
host: \r
connection: keep-alive\r
accept-encoding: gzip\r
accept: application/json\r
\r
{"Cmd":["df","-P"],"Image":"alpine:3.2","Volumes":{},"ExposedPorts":{},"HostConfig":{}}< 2017/06/05 20:24:55.389095  length=213 from=0 to=212
HTTP/1.1 201 Created\r
Api-Version: 1.30\r
Content-Length: 90\r
Content-Type: application/json\r
Date: Mon, 05 Jun 2017 17:24:55 GMT\r
Docker-Experimental: true\r
Ostype: linux\r
Server: Docker/17.06.0-ce-rc1 (linux)\r
\r
< 2017/06/05 20:24:55.389444  length=90 from=213 to=302
{"Id":"511f376a548c986afb0ec74fa3e8d24ab778eaa68c3801639de9dbdf02248551","Warnings":null}
> 2017/06/05 20:25:33.620529  length=234 from=0 to=233
POST /containers/511f376a548c986afb0ec74fa3e8d24ab778eaa68c3801639de9dbdf02248551/start HTTP/1.1\r
content-type: application/json\r
content-length: 2\r
host: \r
connection: keep-alive\r
accept-encoding: gzip\r
accept: application/json\r
\r
{}< 2017/06/05 20:25:33.624507  length=218 from=0 to=217
HTTP/1.1 400 Bad Request\r
Api-Version: 1.30\r
Content-Length: 109\r
Content-Type: application/json\r
Date: Mon, 05 Jun 2017 17:25:33 GMT\r
Docker-Experimental: true\r
Ostype: linux\r
Server: Docker/17.06.0-ce-rc1 (linux)\r
\r
< 2017/06/05 20:25:33.625279  length=109 from=218 to=326
{"message":"starting container with non-empty request body was deprecated since v1.10 and removed in v1.12"}

@KostyaSha
Copy link
Copy Markdown
Member

KostyaSha commented Jun 5, 2017

So it has content-length: 2
and empty {} body but docker fails it?

Very strange because https://github.com/moby/moby/blob/master/api/server/router/container/container_routes.go#L139-L147

@KostyaSha
Copy link
Copy Markdown
Member

Could you try with non osx docker daemon?

@tolkonepiu
Copy link
Copy Markdown
Author

No, sorry.

@KostyaSha
Copy link
Copy Markdown
Member

That looks like docker bug

@tolkonepiu
Copy link
Copy Markdown
Author

I find this: moby/moby#33501

@KostyaSha
Copy link
Copy Markdown
Member

@thaJeztah> Yes, that's a known bug, it's probably something in the proxy

@KostyaSha KostyaSha changed the title Fix start container request in unix socket connection start container request fails for OSX daemon Jun 5, 2017
@KostyaSha KostyaSha closed this Jun 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants