title: install maven in docker
body: <p>I am trying to install and build one file using maven in Dockerfile, but getting an error<code> mvn not found</code>...
  I referred to some articles but I did not find anything</p>
  <p>can anyone please help me to why I am getting this and how to solve this?</p>
  <p>my code</p>
  <pre><code>FROM ubuntu:latest
  MAINTAINER ganeshthirumani
  RUN apt-get update &amp;&amp; apt-get install -y wget
  ARG USER_HOME_DIR=&quot;/root&quot;
  #create a dir foe maven in opt
  RUN mkdir /opt/maven
  RUN mkdir /usr/share/maven
  #RUN mkdir /usr/share/maven
  #dwnl maven using link in tmp
  RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz -O /tmp/maven.tar.gz
  #extract the file
  RUN cd /tmp &amp;&amp; tar xvf maven.tar.gz
  #copy the file into opt/maven
  RUN cp -R /tmp/apache-maven-3.8.4/* /usr/share/maven/
  #RUN cp /opt/files/* /usr/share/maven
  # Install OpenJDK-8
  RUN apt-get update &amp;&amp; \
      apt-get install -y openjdk-8-jdk &amp;&amp; \
      apt-get clean;
      
  # Fix certificate issues
  RUN apt-get update &amp;&amp; \
      apt-get install ca-certificates-java &amp;&amp; \
      apt-get clean &amp;&amp; \
      update-ca-certificates -f;
  
  # Setup JAVA_HOME -- useful for docker commandline
  ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
  RUN export JAVA_HOME
  
  #dwnl zip and move to /opt/files
  RUN mkdir /opt/files
  RUN  wget &lt;this is my zip file&gt; -O /tmp/zip_file.zip
  RUN cp /tmp/zip_file.zip /opt/files/
  
  
  ENV MAVEN_HOME /usr/share/maven
  ENV MAVEN_CONFIG &quot;$USER_HOME_DIR/.m2&quot;
  
  RUN mvn clean install -Pdevelopment
  #RUN mvn clean install -Pdeployment 
  
  
  CMD [&quot;mvn&quot;, &quot;--version&quot;]
  </code></pre>
  <p>and while building...</p>
  <pre><code>Sending build context to Docker daemon  97.28kB
  Step 1/20 : FROM ubuntu:latest
   ---&gt; d13c942271d6
  Step 2/20 : MAINTAINER ganeshthirumani
   ---&gt; Using cache
   ---&gt; 83dbc04930a4
  Step 3/20 : RUN apt-get update &amp;&amp; apt-get install -y wget
   ---&gt; Using cache
   ---&gt; 5a26c629963f
  Step 4/20 : ARG USER_HOME_DIR=&quot;/root&quot;
   ---&gt; Using cache
   ---&gt; fea8fd2bb7f6
  Step 5/20 : RUN mkdir /opt/maven
   ---&gt; Using cache
   ---&gt; 16a42d6b96c3
  Step 6/20 : RUN mkdir /usr/share/maven
   ---&gt; Using cache
   ---&gt; 012f68749248
  Step 7/20 : RUN wget https://dlcdn.apache.org/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz -O /tmp/maven.tar.gz
   ---&gt; Using cache
   ---&gt; dc498bb88baf
  Step 8/20 : RUN cd /tmp &amp;&amp; tar xvf maven.tar.gz
   ---&gt; Using cache
   ---&gt; be08499a07db
  Step 9/20 : RUN cp -R /tmp/apache-maven-3.8.4/* /usr/share/maven/
   ---&gt; Using cache
   ---&gt; 7a705ce7213d
  Step 10/20 : RUN apt-get update &amp;&amp;     apt-get install -y openjdk-8-jdk &amp;&amp;     apt-get clean;
   ---&gt; Using cache
   ---&gt; 452e0b263645
  Step 11/20 : RUN apt-get update &amp;&amp;     apt-get install ca-certificates-java &amp;&amp;     apt-get clean &amp;&amp;     update-ca-certificates -f;
   ---&gt; Using cache
   ---&gt; d65d98457da5
  Step 12/20 : ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
   ---&gt; Using cache
   ---&gt; b8cacc77d6b0
  Step 13/20 : RUN export JAVA_HOME
   ---&gt; Using cache
   ---&gt; 1a5918571b65
  Step 14/20 : RUN mkdir /opt/files
   ---&gt; Using cache
   ---&gt; 66d092f96235
  Step 15/20 : RUN  wget https://drive.google.com/file/d/1IutshyYqlcTw_MkfC1NJzU9AH8B-W2Fa/view?ts=61f24be4 -O /tmp/zip_file.zip
   ---&gt; Using cache
   ---&gt; 7180fa09993b
  Step 16/20 : RUN cp /tmp/zip_file.zip /opt/files/
   ---&gt; Using cache
   ---&gt; bc861eb85449
  Step 17/20 : ENV MAVEN_HOME /usr/share/maven
   ---&gt; Using cache
   ---&gt; be97d22b8558
  Step 18/20 : ENV MAVEN_CONFIG &quot;$USER_HOME_DIR/.m2&quot;
   ---&gt; Using cache
   ---&gt; 7874ed478f2f
  Step 19/20 : RUN mvn clean install -Pdevelopment
   ---&gt; Running in 5b58132ba431
  /bin/sh: 1: mvn: not found
  The command '/bin/sh -c mvn clean install -Pdevelopment' returned a non-zero code: 127
  
  </code></pre>
  <p>and I have seen that the basic directories are:
  for maven home MAVEN_HOME /usr/share/maven
  for config---&gt; MAVEN_CONFIG &quot;$USER_HOME_DIR/.m2 and where user_home_dir is a root</p>
  <p>thanks in advance</p>