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

mvn clean package docker:build failing #105

Closed
samaddico opened this issue Jun 29, 2015 · 20 comments
Closed

mvn clean package docker:build failing #105

samaddico opened this issue Jun 29, 2015 · 20 comments

Comments

@samaddico
Copy link

Hi ,

So I added these to my pom.xml,to build a docker image of my project.But for some reason it fails.

<plugin>
    <groupId>com.spotify</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.2.11</version>
 <configuration>  
       <imageName>nurs-template-engine</imageName>
       <baseImage>java</baseImage>
       <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
     <resources>
           <resource>
                    <targetPath>/</targetPath>
                    <directory>${project.build.directory}</directory>
                    <include>${project.build.finalName}.jar</include>
           </resource>
  </resources>
  </configuration>
</plugin>

I keep having this error. i dont know what it means, i have searched through the web but to no avail.Any help will be much appreciated.

--- docker-maven-plugin:0.2.11:build (default-cli) @ template-engine ---
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Copying /home/dreamadmin/NetBeansProjects/nurs/template-engine/target/template-engine-1.0-SNAPSHOT.jar -> /home/dreamadmin/NetBeansProjects/nurs/template-engine/target/docker/template-engine-1.0-SNAPSHOT.jar
[INFO] Building image nurs-template-engine
Jun 26, 2015 5:36:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Permission denied
Jun 26, 2015 5:36:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Jun 26, 2015 5:36:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Permission denied
Jun 26, 2015 5:36:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
Jun 26, 2015 5:36:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: Permission denied
Jun 26, 2015 5:36:37 PM org.apache.http.impl.execchain.RetryExec execute
INFO: Retrying request to {}->unix://localhost:80
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.777s
[INFO] Finished at: Fri Jun 26 17:36:37 WAT 2015
[INFO] Final Memory: 18M/239M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.2.11:build (default-cli) on project template-engine: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException: java.io.IOException: Permission denied -> [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

Thanks in advance

@vishal-biyani
Copy link

Are you running this from jenkins or from command line?

@samaddico
Copy link
Author

From command.
On Jun 30, 2015 1:07 AM, "Vishal" notifications@github.com wrote:

Are you running this from jenkins or from command line?


Reply to this email directly or view it on GitHub
#105 (comment)
.

@ojacquemart
Copy link

I got the same error running it from a jenkins job.
Any idea of what could cause the exception?

@rohansingh
Copy link
Contributor

Guessing the problem is that your DOCKER_HOST variable is not set correctly. Does docker ps work for you on the same command-line?

@samaddico
Copy link
Author

No please, its not working

On 6 July 2015 at 16:51, Rohan Singh notifications@github.com wrote:

Guessing the problem is that your DOCKER_HOST variable is not set
correctly. Does docker ps work for you on the same command-line?


Reply to this email directly or view it on GitHub
#105 (comment)
.

Samuel Anertey Addico
Software Engineer

Mobile: +2332 040 8005
skype: samuel.addico

@rohansingh
Copy link
Contributor

Sorry, we can't help you without details. What exactly happens when you run docker ps or docker version from the command-line? For example:

$ docker version
Client version: 1.6.0
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 4749651
OS/Arch (client): linux/amd64
Server version: 1.6.0
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 4749651
OS/Arch (server): linux/amd64

@samaddico
Copy link
Author

Response below :

Get http://xxx.xx.xx.x:2376/v1.19/images/json: read tcp xxx.xx.xx.xx:2376: connection reset by peer. Are you trying to connect to a TLS-enabled daemon without TLS?

@rohansingh
Copy link
Contributor

OK, there's some configuration issue with how you've setup Docker. Take a look at the Docker docs and ensure you have things installed and configured correctly. Until the Docker command-line works, there's no way that the Maven plugin will work.

Closing this for now since it's not an issue with docker-maven-plugin.

@alexanderGalushka
Copy link

@ samaddico I have the same exact issue with the same exact log, have you figured what was wrong in your Docker setup?

@samaddico
Copy link
Author

Hi Alex,I did a system restart and it worked.But my team members kept having this same issue,even after i commited to version control system,so i used another plugin.

@hrandika
Copy link

hrandika commented Aug 2, 2015

@samaddico I had the same issue. after I ran docker without 'sudo' permission that solved.It explained here.
http://bsaunder.github.io/2014/12/21/running-docker-without-sudo/

@aksakalli
Copy link

That port is owned by root so you need to run the docker task as root.

sudo mvn docker:build

Or change the user of Docker as @hrandika mentioned: http://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo

@anick16
Copy link

anick16 commented Sep 14, 2016

I too had this issue when I was running the build from Bamboo. It was due to the variable, being used for image name, was in capital letter and docker doesnt allow image names having caps

@vdua
Copy link

vdua commented Mar 8, 2017

I am getting the same error. docker ps and all other docker commands work fine but when running from maven it throws the same error.

 Failed to execute goal com.spotify:docker-maven-plugin:0.4.14-SNAPSHOT:build (default-cli) on 
project cli-sample: Exception caught: Request error: POST 
unix://localhost:80/build?t=example: 500: HTTP 500 Internal Server Error -> [Help 1]

The value of dockerHost is unix:///var/run/docker.sock but in the logs it shows as unix://localhost:80. I debugged and found out that DefaultDockerClient doesn't support this specific port.

@szgz
Copy link

szgz commented Mar 27, 2017

you can try:
add user jenkins to docker group: usermod -G docker jenkins

reason: jenkins should run docker commond, but docker installed as root, so jenkins not have privlege to run docker

@NorrinRadd
Copy link

@vdua That seems like the most valid response I've seen here. Any progress on a fix for that?

@crisnello
Copy link

I my case, I solved to give permission in /var/run/docker for my usr not root

crisnello@debian-crisnello:/home/crisnello$ docker ps
WARNING: Error loading config file: /root/.docker/config.json - stat /root/.docker/config.json: permission denied
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.35/containers/json: dial unix /var/run/docker.sock: connect: permission denied
crisnello@debian-crisnello:/home/crisnello$ sudo docker ps
[sudo] senha para crisnello:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
crisnello@debian-crisnello:/home/crisnello$ ls -l /var/run/docker
ls: não foi possível abrir o diretório '/var/run/docker': Permissão negada
crisnello@debian-crisnello:/home/crisnello$ sudo ls -l /var/run/docker
total 0
drwx------ 3 root root 140 mar 9 08:51 containerd
drw------- 2 root root 60 mar 9 08:51 libnetwork
srwxr-xr-x 1 root root 0 mar 9 08:51 metrics.sock
drwx------ 2 root root 40 mar 9 08:51 plugins
drwx------ 2 root root 40 mar 9 08:51 swarm

crisnello@debian-crisnello:/home/crisnello$ sudo chown -R root:crisnello /var/run/docker*

@tormodatt
Copy link

If you are running it through something like bamboo, remember to restart both docker.service and bamboo-agent.service after adding the user in the docker group. Groups changes are not loaded while its running.

@serdarturkmen
Copy link

add jenkins to docker group
sudo usermod -aG docker jenkins

Then restart your jenkins server to refresh the group.

@mahmoudabbasi
Copy link

please check java version , so check Dockerfile and Dockerdir access 775 and check Dockerfile have a entrypoint.

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