title: Installing and using Gradle in a docker image/container
body: <p>I am getting this strange error at the end of the process of creating a docker image from a <code>Dockerfile</code>:</p>
  
  <pre><code>/bin/sh: 1: gradle: not found
  INFO[0003] The command [/bin/sh -c gradle test jar] returned a non-zero code: 127
  </code></pre>
  
  <p>The relevant part of the <code>Dockerfile</code>:</p>
  
  <pre><code>FROM debian:jessie
  [...]
  RUN curl -L https://services.gradle.org/distributions/gradle-2.4-bin.zip -o gradle-2.4-bin.zip
  RUN apt-get install -y unzip
  RUN unzip gradle-2.4-bin.zip
  RUN echo 'export GRADLE_HOME=/app/gradle-2.4' &gt;&gt; $HOME/.bashrc
  RUN echo 'export PATH=$PATH:$GRADLE_HOME/bin' &gt;&gt; $HOME/.bashrc
  RUN /bin/bash -c "source $HOME/.bashrc"
  RUN gradle test jar
  [...]
  </code></pre>
  
  <p>The command I am using is: <code>docker build -t java_i .</code></p>
  
  <p>The strange thing is that if:</p>
  
  <ul>
  <li>I run a container from the previous image commenting out <code>RUN gradle test jar</code> (command: <code>docker run -d -p 9093:8080 -p 9094:8081 --name java_c -i -t java_i</code>), </li>
  <li>then I log into that container (command: <code>docker exec -it java_c bash</code>), </li>
  <li>then I manually check the gradle environment variables finding them,</li>
  <li>then I manually run that commented out command from within the running container (<code>gradle test jar</code>):</li>
  </ul>
  
  <p>I eventually get the expected output (the compiled java code in the <code>build</code> folder).</p>
  
  <p>I am using Docker version 1.6.2</p>