Skip to content

Commit 9b45d93

Browse files
committed
Use chunked encoding when passing the docker image.
If you don't do this, you very often run out of heap space, as the webclient will create a buffer for the entire image file (possibly many gigabytes) before sending it. Signed-off-by: Nigel Magnay <nigel.magnay@gmail.com>
1 parent 0502d10 commit 9b45d93

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main/java/com/github/dockerjava/jaxrs/BuildImageCmdExec.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import javax.ws.rs.core.MediaType;
99
import javax.ws.rs.core.Response;
1010

11+
import org.glassfish.jersey.client.ClientProperties;
12+
import org.glassfish.jersey.client.RequestEntityProcessing;
1113
import org.slf4j.Logger;
1214
import org.slf4j.LoggerFactory;
1315

@@ -39,6 +41,10 @@ protected InputStream execute(BuildImageCmd command) {
3941
webResource = webResource.queryParam("q", "true");
4042
}
4143

44+
45+
webResource.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.CHUNKED);
46+
webResource.property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024*1024);
47+
4248
LOGGER.debug("POST: {}", webResource);
4349
return webResource
4450
.request()

0 commit comments

Comments
 (0)