Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

mvn docker:build fails with "{}->unix://localhost:80: Connection reset by peer #221

Closed
marcellodesales opened this issue Apr 18, 2016 · 9 comments

Comments

@marcellodesales
Copy link

marcellodesales commented Apr 18, 2016

Description

[INFO] --- docker-maven-plugin:0.4.5:build (default-cli) @ sp-boot-sample ---
[INFO] Copying /home/mdesales/dev/github/intuit/java-service-kit/sp-boot-sample/target/sp-boot-sample-1.0.9-SNAPSHOT.jar -> /home/mdesales/dev/github/intuit/java-service-kit/sp-boot-sample/target/docker/sp-boot-sample-1.0.9-SNAPSHOT.jar
[INFO] Copying src/main/docker/Dockerfile -> /home/mdesales/dev/github/intuit/java-service-kit/sp-boot-sample/target/docker/Dockerfile
[INFO] Building image https://hub.docker.intuit.net/java-service-kit/sp-boot-sample
Apr 18, 2016 3:29:16 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Connection reset by peer
[INFO] ------------------------------------------------------------------------

How to reproduce

  • Created the Dockerfile under src/main/docker/Dockerfile
FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD sp-boot-sample-1.0.9-SNAPSHOT.jar app.jar
RUN sh -c 'touch /app.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
  • Installed the Plugin in pom.xml
            <!-- Build Docker Image from the docker file at src/main/docker/Dockerfile 
                 https://spring.io/guides/gs/spring-boot-docker/
            -->
            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.2.3</version>
                <configuration>
                    <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                    <dockerDirectory>src/main/docker</dockerDirectory>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>

What do you expect

Docker image is built from Maven.

What happened instead

  • Execution Failed. See below.

Software:

  • docker version
$ docker version
Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 15:59:07 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 15:59:07 2016
 OS/Arch:      linux/amd64

$ docker ps                                
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
98f4de116d4a        mysql               "/entrypoint.sh mysql"   12 days ago         Up 12 days          0.0.0.0:3306->3306/tcp   mysql
  • docker-maven-plugin version:
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.4.5</version>
  • maven version:
$ mvn --version
Apache Maven 3.3.3
Maven home: /usr/share/maven
Java version: 1.8.0_74, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.2.0-30-generic", arch: "amd64", family: "unix"

Full backtrace

[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sp-boot-sample ---
[INFO] Building jar: /home/mdesales/dev/github/intuit/java-service-kit/sp-boot-sample/target/sp-boot-sample-1.0.9-SNAPSHOT.jar
[INFO] 
[INFO] --- spring-boot-maven-plugin:1.3.3.RELEASE:repackage (default) @ sp-boot-sample ---
[INFO] 
[INFO] --- docker-maven-plugin:0.4.5:build (default-cli) @ sp-boot-sample ---
[INFO] Copying /home/mdesales/dev/github/intuit/java-service-kit/sp-boot-sample/target/sp-boot-sample-1.0.9-SNAPSHOT.jar -> /home/mdesales/dev/github/intuit/java-service-kit/sp-boot-sample/target/docker/sp-boot-sample-1.0.9-SNAPSHOT.jar
[INFO] Copying src/main/docker/Dockerfile -> /home/mdesales/dev/github/intuit/java-service-kit/sp-boot-sample/target/docker/Dockerfile
[INFO] Building image https://hub.docker.intuit.net/java-service-kit/sp-boot-sample
Apr 18, 2016 3:29:16 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Connection reset by peer
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.056 s
[INFO] Finished at: 2016-04-18T15:29:16-07:00
[INFO] Final Memory: 39M/293M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.4.5:build (default-cli) on project sp-boot-sample: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: org.apache.http.client.ClientProtocolException: Cannot retry request with a non-repeatable request entity: Connection reset by peer -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
  • Executable Jar works as expected. It runs on PORT 8080.
$ java -jar target/sp-boot-sample-1.0.9-SNAPSHOT.jar 

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.3.RELEASE)

   2016-04-18 15:26:27,668 126   | INFO  | context.embedded.AnnotationConfigEmbeddedWebApplicationContext.prepareRefresh#578 ["main" null] Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@6a67f87c: startup date [Mon Apr 18 15:26:27 PDT 2016]; root of context hierarchy     
   2016-04-18 15:26:28,086 544   | INFO  | internal.util.Version.<clinit>#30 ["background-preinit" null] HV000001: Hibernate Validator 5.2.4.Final
@mattnworb
Copy link
Member

Sounds like the docker daemon is closing the connection. See this part of the README, the docker daemon log might have more useful info.

@marcellodesales
Copy link
Author

marcellodesales commented Apr 18, 2016

@mattnworb No... the problem is that the latest plugin is not taking the proper Docker settings. According to #183, the plugin is not taking the settings for the dockerHost.

The solution to go through this is:

  • Properly setup Docker to listen to the HTTP port 2375.

Just make sure Docker's Daemon is setup to start on port 2375. Note that's documented to be insecure. https://docs.docker.com/v1.8/articles/basics/#bind-docker-to-another-host-port-or-a-unix-socket

ExecStart=/usr/bin/docker daemon -H fd:// 

to

ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock
  • Set the DOCKER_HOST to point to either the sock or the HTTP.

With those, I reached the point that it breaks just like #183, which is the intended way.

@marcellodesales
Copy link
Author

Closed this to continue with the #183.

@khteh
Copy link

khteh commented Nov 19, 2018

I am using Maven 3.5.4, Spring Boot 2.1.0 and Docker Maven Plugin 1.4.9 and still bump into the same errors!

@jogindercc
Copy link

Getting same error. And jenkins builder plugin is connected with REST API.

image

@dimmel82
Copy link

dimmel82 commented Aug 19, 2020

In my case the {}->unix://localhost:80: Connection reset by peer error was misleading.
The actual error was invalid reference format: repository name must be lowercase because the image name used contained an uppercase characters and I was only able to see the actual error by manually executing the docker build -t TestImage:1.0 . command.
The docker-maven-plugin worked fine as soon as I fixed the image name in the pom.xml

@robshep
Copy link

robshep commented Aug 23, 2020

As per @dimmel82

In my case the {}->unix://localhost:80: Connection reset by peer error was misleading.
The actual error was invalid reference format: repository name must be lowercase because the image name used contained an uppercase characters and I was only able to see the actual error by manually executing the docker build -t TestImage:1.0 . command.
The docker-maven-plugin worked fine as soon as I fixed the image name in the pom.xml

I was using

<configuration>
    ...
    <tag>${project.version}-${maven.build.timestamp}</tag>
</configuration>

but forgot

<properties>
    ...
    <maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
</properties>

so a spurious ....Z on the timestamp proved to be the uppercase issue as above.

@nadeesha5814
Copy link

If you are running docker desktop or any other docker virtualisation tool make sure that its up and running

@ashish1500616
Copy link

Hey Folks ,

I had the same issue ,solved following :

StackOverflow : Docker mvn plugin make {}->unix://localhost:80: Broken pipe

Thanks .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants