# 指定容器啟動後執行的命令,並且不會被 docker run 提供的參數覆蓋。 ENTRYPOINT ["java","-jar","app.jar"]
Building the docker image
# clean and package the jar file mvn clean package
# build docker image docker build \ --build-arg APP_VERSION=spring-thymeleaf-docker-0.0.1-SNAPSHOT.jar \ # pass APP_VERSION arg for build --tag jerry80409/spring-thymeleaf-docker:0.0.1 . # give a tag for this image
Running image
docker run -d \ # background running --name spring-thymeleaf-docker \ --publish 8080:8080 \ # 指定 local 與 container port 的對應 jerry80409/spring-thymeleaf-docker:0.0.1 # 指定運行的 image 與 image 版本
確認一下執行狀況, 再打開 localhost:8080 確認
docker ps
# list docker process CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 68542645c037 jerry80409/spring-thymeleaf-docker:0.0.1 "java -jar app.jar" 4 seconds ago Up 3 seconds 0.0.0.0:8080->8080/tcp spring-thymeleaf-docker
Remove container and image
# kill docker process by name docker kill spring-thymeleaf-docker