new for docker implementation, trying after R&D.
TASK TO BE ACHIEVED :- To run the docker after a scheduled time (i.e 5 min) through writing CRON.
I have written a simple java application which just contain a println statement. I want to execute the project using Docker.
My Dockerfile
:
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
I executed this command on CMD :- sudo docker build Documents/DockerTest
Processing on cmd :-
Sending build context to Docker daemon 7.159 MB
Step 1/5 : FROM openjdk:8-jre-alpine
---> b1bd879ca9b3
Step 2/5 : RUN mkdir /etc/test/
---> Using cache
---> 4720a4e8fa67
Step 3/5 : RUN chmod 777 /etc/test/
---> Using cache
---> 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
What is the issue exactly with this Docker file.
PROBLEM 2 --
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.
Now , I want to execute a cron job on the docker image i.e to run the particular docker after a fixed time.
i changed my docker to this by more of searching and trying :-
CRONTAB FILE:-
*/10 * * * * root java -jar /etc/test/DockerTesting-0.0.1-SNAPSHOT.jar 2>&1
UPDATED DOCKER FILE:-
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
But it is not working it prints the statement only ones.
Is there anything I am still missing on the Docker file?