docker-java: java.io.IOException: native write() failed : Broken pipe

I’m using the bmuschko/gradle-docker-plugin to build an image for a Spring Boot application. The plugin uses docker-java for the remote tasks.

FROM azul/zulu-openjdk-alpine:11
ADD libs/app-0.0.1-SNAPSHOT.jar /app/
ADD distributions/health-probe.tgz /
RUN mv /health-probe* /scripts
ENTRYPOINT ["java"]
CMD ["-jar", "/app/app-0.0.1-SNAPSHOT.jar"]

This Dockerfile can be used to successfully build an image from the command line but fails with the following exception when ran from Gradle:

Error during callback
java.lang.RuntimeException: java.io.IOException: native write() failed : Broken pipe
        at com.github.dockerjava.httpclient5.ApacheDockerHttpClientImpl.execute(ApacheDockerHttpClientImpl.java:153)
        at com.github.dockerjava.httpclient5.ApacheDockerHttpClient.execute(ApacheDockerHttpClient.java:8)
        at com.github.dockerjava.core.DefaultInvocationBuilder.execute(DefaultInvocationBuilder.java:228)
        at com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:269)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.io.IOException: native write() failed : Broken pipe
        at com.github.dockerjava.httpclient5.UnixDomainSocket$UnixSocketOutputStream.write(UnixDomainSocket.java:319)
        at com.bmuschko.gradle.docker.shaded.org.apache.hc.core5.http.impl.io.SessionOutputBufferImpl.flushBuffer(SessionOutputBufferImpl.java:117)

Also filed corresponding bug https://github.com/bmuschko/gradle-docker-plugin/issues/972.

java --version
openjdk 11.0.7 2020-04-14 LTS
OpenJDK Runtime Environment Zulu11.39+15-CA (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM Zulu11.39+15-CA (build 11.0.7+10-LTS, mixed mode)

Gradle 6.6.1.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 24 (5 by maintainers)

Most upvoted comments

It turns out that docker image names can only contain lowercase letters.

@asarkar Maybe you can try to see how you are naming the image you are trying to build. In micronaut’s case it takes the name from rootProject.name in settings.gradle

@asarkar @bmuschko @bsideup I may have found a way to reproduce this, at least via the gradle-docker-plugin which micronaut uses to build native docker images. If any upper case letters are present in the value of rootProject.name key in settings.gradle, image building will break. Example, rootProject.name="myapp" will work but rootProject.name="Myapp" will NOT work

@bsideup Does this give any hint as to where the problem is?