maryem
(Maryem)
May 27, 2015, 2:01pm
1
Hey there, I’m a beginner in Docker and i want to run a Java application in a docker container, I’m trying to install maven in my dockerfile, but when i press docker build -t username/name_of_app, I get an error : ( E: Unable to locate package maven
INFO[0004] The command [/bin/sh -c apt-get install maven] returned a non-zero code: 100 )
I don’t know how to solve this
Any ideas are welcome
sbasyal
(Sabin Basyal)
May 27, 2015, 6:54pm
2
Please have a look over this official repo for maven: https://registry.hub.docker.com/_/maven/
maryem
(Maryem)
May 28, 2015, 10:00am
3
Thank you @sbasyal for your reply, I changed my dockerfile following the link you sent to me but I still get the same Error :’(
sbasyal
(Sabin Basyal)
May 28, 2015, 8:53pm
4
I just tried and it is working. This is my Dockerfile
FROM maven:3
ADD pom.xml /home/pom.xml
WORKDIR /home
And this is my test pom.xml
file I place in the same location as above Dockerfile
:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Your test folder would look like this:
test
|__ Dockerfile
|__ pom.xml
Now, go to test and do docker build -t mvn-test .
Then, finally do docker run -P mvn-test:latest mvn package
maryem
(Maryem)
May 29, 2015, 7:36am
5
Thank you so much @sbasyal It works
Cheers