spotify / docker-maven-plugin

INACTIVE: A maven plugin for Docker
Apache License 2.0
2.67k stars 575 forks source link

Maven-Docker Build cannot create docker image #357

Closed uelker58 closed 6 years ago

uelker58 commented 6 years ago

Hello, I have the following problem. When building a Docker image with dockerfile, I get the following error message. Docker plugin is used in maven. Strangely enough i can build a docker image in other spring boot applications and there i do not get such an error message. I use docker for windows. I would be pleased if I could help me.

[INFO] Building image portal-appJSF Nov 20, 2017 6:18:37 PM org.apache.http.impl.execchain.RetryExec execute INFORMATION: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:2375: Connection reset by peer: socket write error [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6.721 s [INFO] Finished at: 2017-11-20T18:18:37+01:00 [INFO] Final Memory: 30M/507M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project portal-appJSF: 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: socket write error -> [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

Process finished with exit code 1

microvesalith commented 6 years ago

I encounter the same problem. Did you find a solution?

Under windows, there's a check that has to be set, the Expose daemon on tcp://localhost:2375 without LTS. I have checked it and I was able to run once the build, successfully - and an image was built - but after another run (mvn package) I started having that error. Tried restarting everything with no success.

Output of docker version: Client: Version: 17.09.0-ce API version: 1.32 Go version: go1.8.3 Git commit: afdb6d4 Built: Tue Sep 26 22:40:09 2017 OS/Arch: windows/amd64

Server: Version: 17.09.0-ce API version: 1.32 (minimum version 1.12) Go version: go1.8.3 Git commit: afdb6d4 Built: Tue Sep 26 22:45:38 2017 OS/Arch: linux/amd64 Experimental: true

mattnworb commented 6 years ago

The error message in the original issue indicates that the docker daemon is not listening at the address the plugin is trying to communicate with it at. See the “Setup” section of the readme for how you can customize the address to reach docker at.

microvesalith commented 6 years ago

echo %DOCKER_HOST% tcp://localhost:2375

During the build i get this: [ERROR] Failed to execute goal com.spotify:dockerfile-maven-plugin:1.3.6:build (default) on project AAAa: Execution default of goal com.spotify:dockerfile-maven-plugin:1.3.6:build failed: Illegal char <:> at index 3: tcp://localhost:2375 -> [Help 1]

uelker58 commented 6 years ago

I solved the problem by using the new plugin dockerfile-maven. Was not the deamon as previously mentioned but the plugin.

abhisheknn commented 6 years ago

For me the issue was Capital letter in image name while building the Image . For example following plugin configuration was giving me error .

<plugin>
            <groupId>com.spotify</groupId>
            <artifactId>dockerfile-maven-plugin</artifactId>
            <version>1.3.6</version>
            <configuration>
            <useConfigFile>false</useConfigFile>
            <useMavenSettingsForAuth>true</useMavenSettingsForAuth> 
                <repository>${docker.image.prefix}/dockerAgent</repository>
            <buildArgs>
        <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
            </buildArgs>
            </configuration>
    <executions>
    <execution>
        <id>default</id>
        <phase>install</phase>
        <goals>
            <goal>build</goal>
        </goals>
    </execution>
    </executions>
        </plugin> 

The Issue got resolved by changing the "dockerAgent" to dockeragent (all letters in small cases).

oliviercwa commented 5 years ago

I had the same issue running Docker and Maven on Windows. My configuration tag was

${docker.image.prefix}/${project.artifactId} ... And the ${project.artifactId} resolved to a name that had capital letters. This led to the error "Cannot retry request with a non-repeatable request entity: Connection reset by peer: socket write error -> [Help 1]". Changing the docker image to lowercase fixed it. Thanks abhisheknn
rmoutray-configureone commented 5 years ago

For me the issue was an extra / in the name. My configuration was ${docker.image.prefix}/${project.artifactId}, and the prefix itself already had a /.

liujunshi commented 5 years ago

set class path //设置环境变量 DOCKER_HOST=unix:///var/run/docker.sock or add args before CMD //或者增加启动参数 DOCKER_HOST=unix:///var/run/docker.sock mvn clean install docker:build

ShreyasDeshpande commented 5 years ago

For me the issue was Capital letter in image name while building the Image . For example following plugin configuration was giving me error .

<plugin>
           <groupId>com.spotify</groupId>
           <artifactId>dockerfile-maven-plugin</artifactId>
           <version>1.3.6</version>
           <configuration>
           <useConfigFile>false</useConfigFile>
           <useMavenSettingsForAuth>true</useMavenSettingsForAuth>    
               <repository>${docker.image.prefix}/dockerAgent</repository>
           <buildArgs>
      <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
          </buildArgs>
           </configuration>
   <executions>
   <execution>
      <id>default</id>
      <phase>install</phase>
      <goals>
          <goal>build</goal>
      </goals>
   </execution>
   </executions>
       </plugin> 

The Issue got resolved by changing the "dockerAgent" to dockeragent (all letters in small cases).

It worked for me as well. Thanks a ton :)

BhanuPrakash531 commented 5 years ago

For me the issue was Capital letter in image name while building the Image .

Issue got resolved by changing the upper case to smaller case on the artifact id which is used for the docker image name. Thanks

martinvw commented 5 years ago

I believe this issue should re-opened, there is totally no error message that indicates a problem with uppercase / lowercase. This should be fixed in the plugin.

abdulazizalmalki-gh commented 5 years ago

I had the same issue running Docker and Maven on Windows. My configuration tag was

${docker.image.prefix}/${project.artifactId} ...

And the ${project.artifactId} resolved to a name that had capital letters. This led to the error "Cannot retry request with a non-repeatable request entity: Connection reset by peer: socket write error -> [Help 1]".

Changing the docker image to lowercase fixed it.

Thanks abhisheknn

This fixed it for me. seems to be an issue with the plugin

DRoppelt commented 5 years ago

I can confirm that changing the repository-name to my own value (instead of project.artifactId) fixed this. The ${project.groupId}/${project.artifactId} has upper-case chars.

<plugin>
  <groupId>com.spotify</groupId
  <artifactId>dockerfile-maven-plugin</artifactId>
  <version>1.4.10</version>
...
  <configuration>
    <repository>${project.groupId}/${project.artifactId}</repository>
    <tag>${project.version}</tag>
  </configuration>
</plugin>

to

<plugin>
  <groupId>com.spotify</groupId
  <artifactId>dockerfile-maven-plugin</artifactId>
  <version>1.4.10</version>
...
  <configuration>
    <repository>domain/my_project_name</repository>
    <tag>${project.version}</tag>
  </configuration>
</plugin>
reddyraja86 commented 5 years ago

For me the issue was Capital letter in image name while building the Image . For example following plugin configuration was giving me error .

<plugin>
           <groupId>com.spotify</groupId>
           <artifactId>dockerfile-maven-plugin</artifactId>
           <version>1.3.6</version>
           <configuration>
           <useConfigFile>false</useConfigFile>
           <useMavenSettingsForAuth>true</useMavenSettingsForAuth>  
               <repository>${docker.image.prefix}/dockerAgent</repository>
           <buildArgs>
    <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
        </buildArgs>
           </configuration>
   <executions>
   <execution>
    <id>default</id>
    <phase>install</phase>
    <goals>
        <goal>build</goal>
    </goals>
   </execution>
   </executions>
       </plugin> 

The Issue got resolved by changing the "dockerAgent" to dockeragent (all letters in small cases).

It worked for me as well. Thanks a ton :)

This solved the issue.Thanks.

mohanr commented 5 years ago

Don't understand why we don't think such issues are a serious thread to open-source in contemporary software.

shreekrishna905 commented 4 years ago

Work for me. It is very simple issue. check name of your project. I have name in Uppercase like this name = Xyz. I change to lower case and every thing work fine. ${project.name} = xyz . Thank you all

venkatnaveen7 commented 4 years ago

I too had the same problem We need not remove the capital cases I belive

dockerfile plug in uses project version my pom.xml was having 0.0.1-SNAPSHOT and i changed it to 0.0.1.SNAPSHOT and images built succesfully