Docker Community Forums

Share and learn in the Docker community.

Docker image cannot read / find a .jar file from another image?

build

(Nagarjun Palavalli) #1

I am new to both Java and Docker. I have two Git repositories:

  • project-cms
  • project-app

Both repositories are Java projects. My instructions are to mvn clean install from project-cms and then mvn clean install && mvn build from project-app so that project-app can use the .war file generated by project-cms. I am trying to Dockerize this setup by creating an image of project-cms like this:

FROM maven:3.5.2-jdk-8-alpine
LABEL Name=project-cms Version=1.0.0 

# Container configuration
RUN mkdir /project-cms
COPY . /project-cms
WORKDIR /project-cms
VOLUME /project-cms
RUN mvn clean install

This works fine and I now see an image called project-cms:latest when I do docker image ls. I am trying to use this image to build my project-app like this:

FROM project-cms:latest
LABEL Name=project-app Version=1.0.0 

# Container configuration
RUN mkdir /app
COPY . /app
WORKDIR /app
VOLUME /app
RUN mvn clean install && mvn build
EXPOSE 8080
CMD [ "mvn", "tomcat7:run" ]

My understanding is that the .war file from project-cms should be available to project-app since I am running FROM project-cms:latest above. When I try to build this image, it throws the following error:

[ERROR] Failed to execute goal on project xxxx: Could not resolve dependencies for project com.xxxx:xxxx:war:2.28.1: Could not find artifact com.xxxx:publishing-site:jar:classes:1.02.26 in hippo (http://maven.onehippo.com/maven2/) -> [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/DependencyResolutionException
The command '/bin/sh -c mvn clean install && mvn build' returned a non-zero code: 1

Please note that I have redacted the actual project name with xxxx in the error message above. My thought was to host the project-cms Docker image in our AWS Elastic Container Service so that other developers could just pull that image to build project-app instead of manually installing Maven etc. on each developer machine. Any help to resolve this is appreciated.


(Sam) #2

but you got THAT error… which is neither project-cms, nor project-app

but some OTHER dependency which is not available