There is a difference between images and containers.
- Images will be built ONCE
- You can start containers from Images
In your case:
Change your image:
FROM anapsix/alpine-java
MAINTAINER myNAME
COPY testprj-1.0-SNAPSHOT.jar /home/testprj-1.0-SNAPSHOT.jar
CMD ["java","-jar","/home/testprj-1.0-SNAPSHOT.jar"]
Build your image:
docker build -t imageName .
Now invoke your program inside a container:
docker run --name myProgram imageName
Now restart your program by restarting the container:
docker restart myProgram
Your program changed? Rebuild the image!:
docker rmi imageName
docker build -t imageName .