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

Issue while building docker image #71

Closed
san213 opened this issue Apr 14, 2015 · 12 comments
Closed

Issue while building docker image #71

san213 opened this issue Apr 14, 2015 · 12 comments
Labels

Comments

@san213
Copy link

san213 commented Apr 14, 2015

I am stuck at the below error while trying to build the docker image. I was using 0.1.1 maven plugin, but even after 0.2.6 there has been no help. Can anyone please tell how to solve this?

Caused by: com.spotify.docker.client.shaded.javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
        at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:968)
        at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:795)
        at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:91)
        at org.glassfish.jersey.client.JerseyInvocation$5.completed(JerseyInvocation.java:756)
        at org.glassfish.jersey.client.ClientRuntime.processResponse(ClientRuntime.java:189)
        at org.glassfish.jersey.client.ClientRuntime.access$300(ClientRuntime.java:74)
        at org.glassfish.jersey.client.ClientRuntime$1.run(ClientRuntime.java:171)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
        at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
        at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
        at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:320)
        at org.glassfish.jersey.client.ClientRuntime$2.run(ClientRuntime.java:201)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:745)
@davidxia
Copy link
Contributor

What command are you running and have you set the docker environmental variables like DOCKER_HOST if you need them?

@san213
Copy link
Author

san213 commented Apr 15, 2015

Yes, I have set the docker variables like below.

DOCKER_HOST=tcp://192.168.59.103:2376
DOCKER_TLS_VERIFY=0
DOCKER_CERT_PATH=/Users/santosh/.boot2docker/certs/boot2docker-vm

I am running the docker build image command and stuck at this error.

mvn clean package docker:build

@davidxia
Copy link
Contributor

@san213 And docker ps works? Are you using boot2docker? What version of docker is it running? What's the output of /var/log/docker.log in the boot2docker vm?

@MarekCyzio
Copy link

I have the same issue. Plugin settings are:

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                    <baseImage>8623bfc2fe4a</baseImage>
                    <maintainer>Marek Cyzio</maintainer>
                    <dockerHost>http://172.26.8.56:6667</dockerHost>
                    <imageName>${project.artifactId}-${project.version}</imageName>
                    <entryPoint>/usr/local/tomcat/bin/startup.sh</entryPoint>
                    <exposes>
                        <expose>8080</expose>
                    </exposes>
                    <resources>
                        <resource>
                        <targetPath>/usr/local/tomcat/webapps</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.war</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>

The Maven output is:

DEBUG] Configuring mojo 'com.spotify:docker-maven-plugin:0.2.6:build' with basic configurator -->
DEBUG]   (f) baseImage = 8623bfc2fe4a
DEBUG]   (f) buildDirectory = C:\_home\xxx\xxx\xxx\target
DEBUG]   (f) dockerHost = http://172.26.8.56:6667
DEBUG]   (f) entryPoint = /usr/local/tomcat/bin/startup.sh
DEBUG]   (f) env = {}
DEBUG]   (f) exposes = [8080]
DEBUG]   (f) imageName = xxx-0.0.1-SNAPSHOT
DEBUG]   (f) imageTags = []
DEBUG]   (f) maintainer = Marek Cyzio
DEBUG]   (f) mavenProject = MavenProject: com.equifax.ird:xxx:0.0.1-SNAPSHOT @ C:\_home\xxx\xxx\xxx\pom.xml
DEBUG]   (f) pushImage = false 
DEBUG]   (s) targetPath = /usr/local/tomcat/webapps
DEBUG]   (s) directory = C:\_home\xxx\xxx\xxx\target
DEBUG]   (s) include = xxx-0.0.1-SNAPSHOT.war
DEBUG]   (f) resources = [Resource {targetPath: /usr/local/tomcat/webapps, filtering: false, FileSet {directory: C:\_home\xxx\xxx\xxx\target, PatternSet includes: {xxx-0.0.1-SNAPSHOT.war}, excludes: {}]}}]
DEBUG]   (f) skipDockerBuild = false
DEBUG]   (f) tagInfoFile = C:\_home\xxx\xxx\xxx\target\test-classes/image_info.json
DEBUG]   (f) useGitCommitId = false
DEBUG]   (f) execution = com.spotify:docker-maven-plugin:0.2.6:build {execution: default-cli}
DEBUG]   (f) session = org.apache.maven.execution.MavenSession@53ab0286
DEBUG]   (f) settings = org.apache.maven.execution.SettingsAdapter@2d10e0b1
DEBUG] -- end configuration --
DEBUG] Not using any build profile
INFO] Copying C:\_home\xxx\xxx\xxx\target\xxx-0.0.1-SNAPSHOT.war -> C:\_home\xxx\xxx\xxx\target\docker\usr\local\tomcat\webapps\xxx-0.0.1-SNAPSHOT.war
INFO] Building image xxx-0.0.1-SNAPSHOT
INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
INFO] ------------------------------------------------------------------------
INFO] Total time: 28.320 s
INFO] Finished at: 2015-04-15T16:58:17-04:00
INFO] Final Memory: 16M/203M
INFO] ------------------------------------------------------------------------
ERROR] Failed to execute goal com.spotify:docker-maven-plugin:0.2.6:build (default-cli) on project xxx: Exception caught: Request error: POST http://172.26.8.56:6667/v1.12/build?t=xxx-0.0.1-SNAPSHOT: 500: HTTP 500 Internal Server Error -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.spotify:docker-maven-plugin:0.2.6:build (default-cli) on project xxx: Exception caught
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
       at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
       at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
       at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
       at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)
       at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
       at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
       at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)
       at org.apache.maven.cli.MavenCli.main(MavenCli.java:160)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
       at java.lang.reflect.Method.invoke(Method.java:483)
       at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
       at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
       at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
       at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
caused by: org.apache.maven.plugin.MojoExecutionException: Exception caught
       at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:117)
       at com.spotify.docker.BuildMojo.execute(BuildMojo.java:79)
       at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
       at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
       ... 19 more
caused by: com.spotify.docker.client.DockerRequestException: Request error: POST http://172.26.8.56:6667/v1.12/build?t=xxx-0.0.1-SNAPSHOT: 500
       at com.spotify.docker.client.DefaultDockerClient.propagate(DefaultDockerClient.java:1061)
       at com.spotify.docker.client.DefaultDockerClient.request(DefaultDockerClient.java:1010)
       at com.spotify.docker.client.DefaultDockerClient.build(DefaultDockerClient.java:787)
       at com.spotify.docker.BuildMojo.buildImage(BuildMojo.java:456)
       at com.spotify.docker.BuildMojo.execute(BuildMojo.java:263)
       at com.spotify.docker.AbstractDockerMojo.execute(AbstractDockerMojo.java:115)
       ... 22 more
caused by: com.spotify.docker.client.shaded.javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
       at org.glassfish.jersey.client.JerseyInvocation.convertToException(JerseyInvocation.java:968)
       at org.glassfish.jersey.client.JerseyInvocation.translate(JerseyInvocation.java:795)
       at org.glassfish.jersey.client.JerseyInvocation.access$500(JerseyInvocation.java:91)
       at org.glassfish.jersey.client.JerseyInvocation$5.completed(JerseyInvocation.java:756)
       at org.glassfish.jersey.client.ClientRuntime.processResponse(ClientRuntime.java:189)
       at org.glassfish.jersey.client.ClientRuntime.access$300(ClientRuntime.java:74)
       at org.glassfish.jersey.client.ClientRuntime$1.run(ClientRuntime.java:171)
       at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
       at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
       at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
       at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
       at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
       at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:320)
       at org.glassfish.jersey.client.ClientRuntime$2.run(ClientRuntime.java:201)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
       at java.util.concurrent.FutureTask.run(FutureTask.java:266)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
       at java.lang.Thread.run(Thread.java:745)

Generated Dockerfile is:

FROM 8623bfc2fe4a
MAINTAINER Marek Cyzio
ENTRYPOINT /usr/local/tomcat/bin/startup.sh
CMD []
ADD \usr\local\tomcat\webapps\xxx-0.0.1-SNAPSHOT.war \usr\local\tomcat\webapps\xxx-0.0.1-SNAPSHOT.war
EXPOSE 8080

Edit - I think I found the root cause - Docker daemon log says:

Invalid repository name (xxx-xxx-xxx-xxx-0.0.1-SNAPSHOT), only [a-z0-9-_.] are allowed
[79832e01] -job build() = ERR (1)

So it looks like uppercase SNAPSHOT is causing isues?

@rammic
Copy link

rammic commented Apr 21, 2015

Had the same issue and @MarekCyzio's suggestion fixed it for me (though it's not just 'SNAPSHOT', but any package name with uppercase letters). Thanks.

@jstanier
Copy link

Thanks for working this out. Is this something worth fixing? I've just run into the same issue because we build DEV-SNAPSHOT versions locally.

@davidxia
Copy link
Contributor

davidxia commented Aug 3, 2015

(I'll assume this upper case issue is what caused OP's error.)

Docker doesn't let you build images whose repository names have upper case letters. This isn't something we can fix in docker-maven-plugin. We could emit a better error message though.

Doesn't the java package naming convention say to use only lowercase?

@aburnett
Copy link

I'm having a similar issue after a maven clean. From boot2docker logs:

time="2015-08-12T13:41:23.838749808Z" level=debug msg="Calling POST /build" 
time="2015-08-12T13:41:23.838844666Z" level=info msg="POST /build?t=xxxx/spar-api:a900d3c.DIRTY" 
time="2015-08-12T13:41:30.706516239Z" level=error msg="Handler for POST /build returned error: Cannot locate specified Dockerfile: Dockerfile" 
time="2015-08-12T13:41:30.706572072Z" level=error msg="HTTP Error" err="Cannot locate specified Dockerfile: Dockerfile" statusCode=500 

@mattnworb
Copy link
Member

I've added some notes to the README in #148 regarding these causes of 500 Internal Server Error to document some of these problems for users in the future.

@dskow
Copy link

dskow commented Nov 29, 2016

Dockerfile is case sensitive. make sure yours is not DockerFile or something similar.

@cs94njw
Copy link

cs94njw commented Feb 13, 2017

I had the same error. Turned out my "ENV" command in my DockerFile had spaces in, and needed to be wrapped in double quotes.
This kind of error can't be returned to the caller???

@raghuchowdareddy
Copy link

Hi,
Even I had faced above issue along with http 500 server exception
Make sure below steps are working and in place

  1. docker ps
  2. docker-machine ls (at least default machine should be running)
    Some time docker-machine may not start properly. So I end up doing re-install the docker and start the docker-machine again
    $docker-machine env default
    export DOCKER_TLS_VERIFY="1"
    export DOCKER_HOST="tcp://192.168.99.100:2376"
    export DOCKER_CERT_PATH="/Users/user-name/.docker/machine/machines/default"
    export DOCKER_MACHINE_NAME="default"
  3. Important: make sure you have the dockerfile naming convension as

"Dockerfile"

NOT

"DockerFile"

Because, i have seen some sites suggested to name like DockerFile, but it did not work for me
3. In pom.xml check the configuration as below
<configuration> <dockerCertPath>/Users/username/.docker/machine/machines/default</dockerCertPath> <imageName>enterimangename</imageName> <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory> <dockerHost>https://192.168.99.100:2376</dockerHost> <serverId>docker-hub</serverId> <registryUrl>https://index.docker.io/v1/</registryUrl> <resources> <resource> <targetPath>/</targetPath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource> </resources> </configuration>
4. But last but not least in maven settings.xml
<server> <id>docker-hub</id> <username>username</username> <password>pwd</password> <configuration> <email>abc@abc.com</email> </configuration> </server>
5. Finally do "mvn clean install"

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

No branches or pull requests

10 participants