dockerfile - Run jar file in docker image -
i create docker image java , coppying jar file in image . dockerfile :
from anapsix/alpine-java maintainer myname copy testprj-1.0-snapshot.jar /home/testprj-1.0-snapshot.jar run java -jar /home/testprj-1.0-snapshot.j
after execute following command
docker build -t imagename.
in console see output application , everthing fine . when stop image don`t know how run image again ? when execute following command :
docker run -i -t imagename java -jar /home/testprj-1.0-snapshot.jar
the application run again ,but in dockerfile wrote command. how run image without command , application run automatically ?
there difference between images , containers.
- images build once
- you can start containers images
in case:
change 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 image:
docker build -t imagename .
now invoke program inside container:
docker run --name myprogram imagename
now restart program restarting container:
docker restart myprogram
your program changed? rebuild image!:
docker rmi imagename docker build -t imagename .
Comments
Post a Comment