Title: Start Container Constructs Incorrect POST · Issue #615 · docker-java/docker-java · GitHub
Open Graph Title: Start Container Constructs Incorrect POST · Issue #615 · docker-java/docker-java
X Title: Start Container Constructs Incorrect POST · Issue #615 · docker-java/docker-java
Description: 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 rel...
Open Graph Description: 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.) Thi...
X Description: 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.) Thi...
Opengraph URL: https://github.com/docker-java/docker-java/issues/615
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Start Container Constructs Incorrect POST","articleBody":"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.) \n\nThis Scala program reproduces the error reliably (against Docker 1.12):\n\n``` scala\npackage com.github.m4dc4p.dockerjava\n\nobject Main extends App {\n\n import com.github.dockerjava.core._\n import com.github.dockerjava.api._\n\n val docker: DockerClient = DockerClientBuilder.getInstance(\n DockerClientConfig.createDefaultConfigBuilder()\n // .withDockerHost(\"tcp://127.0.0.1:2375\") // uncomment for windows\n .withApiVersion(\"1.21\")\n .build())\n .build()\n\n val container = docker.createContainerCmd(\"mysql/mysql-server:latest\")\n .withEnv(\"MYSQL_ALLOW_EMPTY_PASSWORD=yes\")\n .exec()\n\n docker.startContainerCmd(container.getId).exec() // HTTP 500/HTTP 400\n}\n```\n\nHere is a trace of the relevant output. I marked the garbage in the body of the POST request with `***`:\n\n```\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"POST /v1.21/containers/34e03000dab1be0bc41cd5acd55dae34aa2eb3b743c5c92b3a9c150209a42452/start HTTP/1.1[\\r][\\n]\"\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"Accept: application/json[\\r][\\n]\"\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"Content-Type: application/json[\\r][\\n]\"\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"User-Agent: Jersey/2.11 (Apache HttpClient 4.3.1)[\\r][\\n]\"\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"Transfer-Encoding: chunked[\\r][\\n]\"\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"Host: 127.0.0.1:2375[\\r][\\n]\"\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"Connection: Keep-Alive[\\r][\\n]\"\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"Accept-Encoding: gzip,deflate[\\r][\\n]\"\n764 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"[\\r][\\n]\"\n***765 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"2[\\r][\\n]\"\n***765 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"{}[\\r][\\n]\"\n***765 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"0[\\r][\\n]\"\n765 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003e\u003e \"[\\r][\\n]\"\n768 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003c\u003c \"HTTP/1.1 500 Internal Server Error[\\r][\\n]\"\n768 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003c\u003c \"Content-Length: 4[\\r][\\n]\"\n768 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003c\u003c \"Content-Type: text/plain; charset=utf-8[\\r][\\n]\"\n768 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003c\u003c \"Date: Tue, 21 Jun 2016 10:27:16 GMT[\\r][\\n]\"\n768 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003c\u003c \"Server: Docker/1.12.0-rc2 (linux)[\\r][\\n]\"\n768 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003c\u003c \"X-Content-Type-Options: nosniff[\\r][\\n]\"\n768 [main] DEBUG org.apache.http.wire - http-outgoing-0 \u003c\u003c \"[\\r][\\n]\"\n768 [main] DEBUG org.apache.http.headers - http-outgoing-0 \u003c\u003c HTTP/1.1 500 Internal Server Error\n```\n\nNote that removing the API version results in an HTTP 400.\n\nThe `.../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`.\n","author":{"url":"https://github.com/m4dc4p","@type":"Person","name":"m4dc4p"},"datePublished":"2016-06-21T23:34:04.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":14},"url":"https://github.com/615/docker-java/issues/615"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ef358306-508b-20d2-dacf-28c0d24464f7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA74:5F375:9AF427:D6156E:69738615 |
| html-safe-nonce | 58837cc5fa2b21216f24677f901dca30a12efe20b25ca92579ed6e26988f3b15 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTc0OjVGMzc1OjlBRjQyNzpENjE1NkU6Njk3Mzg2MTUiLCJ2aXNpdG9yX2lkIjoiMTE2ODE0MTk4NTcwOTc4NjY0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a24e6729a6bedff2ceef089b0afb3eabca09a993bbc549cccb2eb75b7371c906 |
| hovercard-subject-tag | issue:161563577 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/docker-java/docker-java/615/issue_layout |
| twitter:image | https://opengraph.githubassets.com/389656f414bffc68bcc66f6374bd0ef8198996ca6855aef221bfb09bcf050019/docker-java/docker-java/issues/615 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/389656f414bffc68bcc66f6374bd0ef8198996ca6855aef221bfb09bcf050019/docker-java/docker-java/issues/615 |
| og:image:alt | 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.) Thi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | m4dc4p |
| hostname | github.com |
| expected-hostname | github.com |
| None | f0b5e2d1da32de5a0b7bcfbc5ba007c93e8e63098fba29e1200efb674aa72e66 |
| turbo-cache-control | no-preview |
| go-import | github.com/docker-java/docker-java git https://github.com/docker-java/docker-java.git |
| octolytics-dimension-user_id | 7772003 |
| octolytics-dimension-user_login | docker-java |
| octolytics-dimension-repository_id | 20415251 |
| octolytics-dimension-repository_nwo | docker-java/docker-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20415251 |
| octolytics-dimension-repository_network_root_nwo | docker-java/docker-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | c96653671324f9b6d4c5f787435acf56a06087dd |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width