title: Execute a simple java application using Docker
body: <p>new for docker implementation, trying after R&amp;D.</p>
  
  <p><strong>TASK TO BE ACHIEVED</strong> :- To run the docker after a scheduled time (i.e 5 min) through writing CRON.</p>
  
  <p>I have written a simple java application which just contain a println statement. I want to execute the project using Docker.</p>
  
  <p>My <code>Dockerfile</code>:</p>
  
  <pre><code>FROM openjdk:8-jre-alpine
  RUN mkdir /etc/test/
  RUN chmod 777 /etc/test/
  COPY /home/administrator/Documents/LearningWorkspace/DockerTesting/target/DockerTesting-0.0.1-SNAPSHOT.jar /etc/test/
  CMD java -Xmx500M -jar /etc/test/DockerTesting-0.0.1-SNAPSHOT.jar
  </code></pre>
  
  <p>I executed this command on CMD :- <strong>sudo docker build Documents/DockerTest</strong></p>
  
  <p><em>Processing on cmd :-</em></p>
  
  <pre><code>Sending build context to Docker daemon 7.159 MB
  Step 1/5 : FROM openjdk:8-jre-alpine
   ---&gt; b1bd879ca9b3
  Step 2/5 : RUN mkdir /etc/test/
   ---&gt; Using cache
   ---&gt; 4720a4e8fa67
  Step 3/5 : RUN chmod 777 /etc/test/
   ---&gt; Using cache
   ---&gt; 91426c394ae4
  Step 4/5 : COPY /home/administrator/Documents/LearningWorkspace/DockerTesting/target/DockerTesting-0.0.1-SNAPSHOT.jar /etc/test/
  lstat home/administrator/Documents/LearningWorkspace/DockerTesting/target/DockerTesting-0.0.1-SNAPSHOT.jar: no such file or directory
  </code></pre>
  
  <h2>What is the issue exactly with this Docker file.</h2>
  
  <p><strong>PROBLEM 2 --</strong> </p>
  
  <p>Now , My docker file has been successfully executed and on Running the docker Image the println statement of java application is printed on the console.</p>
  
  <p>Now , I want to execute a cron job on the docker image i.e to run the particular docker after a fixed time.</p>
  
  <p>i changed my docker to this by more of searching and trying :-</p>
  
  <p><strong>CRONTAB FILE:-</strong></p>
  
  <pre><code>*/10 * * * * root java -jar /etc/test/DockerTesting-0.0.1-SNAPSHOT.jar 2&gt;&amp;1
  </code></pre>
  
  <p><strong>UPDATED DOCKER FILE:-</strong></p>
  
  <pre><code>FROM openjdk:8-jre-alpine
  RUN mkdir /etc/test/
  RUN chmod 777 /etc/test/
  ADD crontab /etc/cron
  ADD jar/ /etc/test/
  RUN chmod 0600 /etc/cron
  CMD java -Xmx500M -jar /etc/test/DockerTesting-0.0.1-SNAPSHOT.jar
  </code></pre>
  
  <p>But it is not working it prints the statement only ones.</p>
  
  <p>Is there anything I am still missing on the Docker file?</p>
  
  <p>The links i refered to <a href="https://www.ekito.fr/people/run-a-cron-job-with-docker/" rel="nofollow noreferrer">Link 1</a>
  <a href="https://gist.github.com/mhubig/a01276e17496e9fd6648cf426d9ceeec" rel="nofollow noreferrer">Link 2</a></p>