In docker-java-3.0.0, the StartContainerCmdExec class sends a POST to the Docker API with garbage in the request body, resulting in an HTTP 400 or HTTP 500 (depending on the version of Docker.)
This Scala program reproduces the error reliably (against Docker 1.12):
Note that removing the API version results in an HTTP 400.
The .../start endpoint supports a (deprecated) HostConfig JSON blob in the body, and docker-java must have supported that at some point. However, the StartContainerCmd interface does not allow you to add such a thing to the request, but StartContainerCmdExec contains some vestige of the old behavior and tries to add a JSON blob to the post body. The fix is simple - pass null to the post request in com.github.dockerjava.jaxrs.StartContainerCmdExec#execute.
Reacted by lukasniemeier-zalando, Mathias Düsterhöft, Patrick Schmidt and Loki-Afro
bitsofinfo posted this in our ISSUES and as such we're able to get docker-java working on mac with this hack of sorts ... which is great. However, docker on mac is currently on 1.12 and suffers from this same issue. Trying to do as @KostyaSha noted above, and setting the apiVersion to an earlier version (went all the way back to 1.21) results in the below exception. Any ideas? Maybe a docker/mac bug of sorts?
at com.github.dockerjava.jaxrs.filter.ResponseStatusExceptionFilter.filter(ResponseStatusExceptionFilter.java:53)
at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:134)
at org.glassfish.jersey.client.ClientFilteringStages$ResponseFilterStage.apply(ClientFilteringStages.java:123)
at org.glassfish.jersey.process.internal.Stages.process(Stages.java:171)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:251)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:667)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:664)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:664)
at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:424)
at org.glassfish.jersey.client.JerseyInvocation$Builder.post(JerseyInvocation.java:333)
at com.github.dockerjava.jaxrs.StartContainerCmdExec.execute(StartContainerCmdExec.java:29)
at com.github.dockerjava.jaxrs.StartContainerCmdExec.execute(StartContainerCmdExec.java:14)
at com.github.dockerjava.jaxrs.AbstrSyncDockerCmdExec.exec(AbstrSyncDockerCmdExec.java:23)
at com.github.dockerjava.core.command.AbstrDockerCmd.exec(AbstrDockerCmd.java:35)
at com.github.dockerjava.core.command.StartContainerCmdImpl.exec(StartContainerCmdImpl.java:46)
at com.github.dockerjava.api.command.StartContainerCmd$exec.call(Unknown Source)
at com.bmuschko.gradle.docker.tasks.container.DockerStartContainer.runRemoteCommand(DockerStartContainer.groovy:23)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask$_start_closure1.doCall(AbstractDockerRemoteApiTask.groovy:57)
at com.bmuschko.gradle.docker.utils.DockerThreadContextClassLoader.withClasspath(DockerThreadContextClassLoader.groovy:53)
at com.bmuschko.gradle.docker.utils.ThreadContextClassLoader$withClasspath.call(Unknown Source)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask.runInDockerClassPath(AbstractDockerRemoteApiTask.groovy:62)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask$runInDockerClassPath.callCurrent(Unknown Source)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask$runInDockerClassPath.callCurrent(Unknown Source)
at com.bmuschko.gradle.docker.tasks.AbstractDockerRemoteApiTask.start(AbstractDockerRemoteApiTask.groovy:56)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:228)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
... 60 more
Hm.. i have PR with updated jersey and deps in #620 but it started failing with connection pool. I think our problem now that we IT doesn't pass on travis :(
Fixed start to not send body, related only to jersey as netty decodes body in different way.
If it will repeat for some calls, will require more proper fix.
Activity
marcuslinke commented on Jun 22, 2016
Thanks for reporting. Thats definitely a bug but it works with older remote API 1.23 therefore it wasn't found already.
KostyaSha commented on Jun 22, 2016
Why bug? HostConfig isn't supported. In connection set apiVersion to 1.23 and everything would continue working. 1.24 support will be added later.
marcuslinke commented on Jun 22, 2016
One would call it a bug because we sent an empty json object with the POST which is wrong for v1.22 also.
cdancy commented on Jul 4, 2016
bitsofinfo posted this in our ISSUES and as such we're able to get docker-java working on mac with this hack of sorts ... which is great. However, docker on mac is currently on 1.12 and suffers from this same issue. Trying to do as @KostyaSha noted above, and setting the apiVersion to an earlier version (went all the way back to 1.21) results in the below exception. Any ideas? Maybe a docker/mac bug of sorts?
Caused by: com.github.dockerjava.api.exception.InternalServerErrorException: EOF
KostyaSha commented on Jul 4, 2016
@cdancy try open wireshark and dump request/responses.
KostyaSha commented on Jul 4, 2016
@cdancy does docker CLI works when you target it to versioned endpoint?
cdancy commented on Jul 4, 2016
Docker CLI works with all version as does curl. Pasted the curl output for the default as well as a specific version below.
Curling with default (which is api v1.24):
Curling with specific api:
KostyaSha commented on Jul 4, 2016
Hm.. i have PR with updated jersey and deps in #620 but it started failing with connection pool. I think our problem now that we IT doesn't pass on travis :(
cdancy commented on Jul 4, 2016
@KostyaSha if you need someone to test with an in-dev version of docker-java feel free to ping me when you've got things ironed out.
KostyaSha commented on Jul 4, 2016
@cdancy atm i think only @marcuslinke remember what he hacked in ApacheConnector
KostyaSha commented on Jul 12, 2016
UPD: master has fresh deps
KostyaSha commented on Jul 12, 2016
Could somebody provide test case in java?
m4dc4p commented on Jul 12, 2016
@KostyaSha
KostyaSha commented on Aug 15, 2016
Fixed start to not send body, related only to jersey as netty decodes body in different way.
If it will repeat for some calls, will require more proper fix.