使用gradle結合docker
安裝
安裝Gradle
安裝Docker
https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04
下載範例專案
git clone https://github.com/codedata/JavaTutorial/tree/master/exercises/exercise10/BasicWeb
cd /JavaTutorial/exercises/exercise10/BasicWeb打包成war
在build.gradle同層路徑輸入 :
gradle tomcatRunWar把war檔放入Docker執行
http://codeomitted.com/deploy-war-file-to-docker-image/
新增檔案名為 : Dockerfile
# Pull base image
From tomcat:8-jre8
# Maintainer
MAINTAINER "xxx <xxx@gmail.com">
# Copy to images tomcat path
ADD BasicWeb.war /usr/local/tomcat/webapps/然後build
docker build -t webserver .執行
docker run -it --rm -p 8080:8080 --name dockerwar webserverLast updated
Was this helpful?