1:在项目的pom目录下新建Dockerfile文件
2:编写Dockerfile(依赖于maven镜像)
FROM registry.cn-hangzhou.aliyuncs.com/acs/maven
ENV MY_HOME=/usr/src/app
RUN mkdir -p $MY_HOME
WORKDIR $MY_HOME
ADD pom.xml $MY_HOME
# get all the downloads out of the way
RUN ["/usr/local/bin/mvn-entrypoint.sh","mvn","verify","clean","--fail-never"]
# add source
ADD . $MY_HOME
# run maven install
RUN ["/usr/local/bin/mvn-entrypoint.sh","mvn","install"]
ENTRYPOINT ["java","-jar","/usr/src/app/target/girl-0.0.1-SNAPSHOT.jar"]
3:执行Dockerfile,编译项目镜像
docker build -t 镜像名称 -f Dockerfile .
4:执行编译好的镜像
docker run -d -p 8889:8082 镜像名称