amihaiemil / docker-java-api

Lightweight Java Docker client
BSD 3-Clause "New" or "Revised" License
270 stars 53 forks source link

Exception while trying to use Logs.fetch() with docker 18.09 #256

Closed nmaguiar closed 5 years ago

nmaguiar commented 5 years ago

Using release 0.0.6 in a container, with docker 18.09, fails whenever trying to use the logs().fetch() method for another container with the following exception:

com.amihaiemil.docker.UnexpectedResponseException: Expected status 200 but got 400 when calling unix://localhost:80/v1.35/containers/a589995677a2511cd8db4a72e79e04d1b33467f27cf951896f3129f22dca88c4/logs. Response body was {"message":"Bad parameters: you must choose at least one stream"}
        at com.amihaiemil.docker.MatchStatus.handleResponse(MatchStatus.java:66)
        at com.amihaiemil.docker.MatchStatus.handleResponse(MatchStatus.java:39)
        at com.amihaiemil.docker.ReadString.handleResponse(ReadString.java:57)
        at com.amihaiemil.docker.ReadString.handleResponse(ReadString.java:39)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:140)
        at com.amihaiemil.docker.HttpClientEnvelope.execute(HttpClientEnvelope.java:103)
        at com.amihaiemil.docker.RtLogs.fetch(RtLogs.java:84)
[...]

From what I understood from "Bad parameters: you must choose at least one stream", it looks like it's necessary to specify if its stdout or stderr since both, by default, are false.

0crat commented 5 years ago

@amihaiemil/z please, pay attention to this issue

0crat commented 5 years ago

@nmaguiar/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!

amihaiemil commented 5 years ago

@nmaguiar thanks, definetely a bug. And many thanks for the donation, much appreciated.

We'll fix it asap. In the meantime, try to use this ctor, perhaps you can use the API version 1.39? Long shot, but maybe it works.

0crat commented 5 years ago

Thanks for your contribution, @nmaguiar/z! If you would be a member of the project, you would now earn +15 reputation points, as explained in §29. You can join and apply to it, see §2.

0crat commented 5 years ago

The job #256 assigned to @amihaiemil/z, here is why; the budget is 30 minutes, see §4; please, read §8 and §9; if the task is not clear, read this and this; there will be no monetary reward for this job

0crat commented 5 years ago

Job gh:amihaiemil/docker-java-api#256 already assigned to @amihaiemil, can't assign to @amihaiemil

0crat commented 5 years ago

Manual assignment of issues is discouraged, see §19: -5 point(s) just awarded to @amihaiemil/z

nmaguiar commented 5 years ago

@nmaguiar thanks, definetely a bug. And many thanks for the donation, much appreciated.

We'll fix it asap. In the meantime, try to use this ctor, perhaps you can use the API version 1.39? Long shot, but maybe it works.

Thank you. Just tried with v1.39 but, unfortunately, got the same exception.

amihaiemil commented 5 years ago

@nmaguiar fixed. For now, it'll read both stdout and sterr, there is a puzzle to make that customizable. Version 0.0.7 is released, you should be able to take it from Maven Central already.

Can you close this? If I do it, I think the PM will complain :D

Btw, Logs.toString() does a .fetch() behind, so you can use that, if you want your code shorter (println(container.logs()) is the same as println(container.logs().fetch())).

nmaguiar commented 5 years ago

@amihaiemil, Thank you a lot :) Just tested 0.0.7 and it solved my problem.

0crat commented 5 years ago

Job was finished in 1 hours, bonus for fast delivery is possible (see §36)

0crat commented 5 years ago

The job #256 is now out of scope

0crat commented 5 years ago

Order was finished: +35 point(s) just awarded to @amihaiemil/z