1、spring boot通用写法
FROM java:latest
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
ADD /app/app.jar /app/app.jar
ENTRYPOINT ["java","-jar","/app/app.jar"]
2、写入配置文件地址写法
FROM java:latest
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
ENTRYPOINT ["java","-jar","-Dspring.config.location=/app/conf/application-prod.yml","/app/robotapi-0.0.1-SNAPSHOT.jar"]
3、指定java版本写法
#版本为java8
FROM java:8
#将所有jar包复制
COPY *.jar /app.jar
#服务端口号
CMD ["--server.port=8080"]
#容器启动的时候运行的命令
ENTRYPOINT ["java","-jar","/app.jar"
4、通用写法1
FROM java:latest
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
ENTRYPOINT ["java","-jar","--spring.profiles.active=prod -Dspring.config.location=/app/conf/application-prod.yml","/app/app.jar"]
5、docker配置国内镜像地址
{
"registry-mirrors": [
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com"
]
}
systemctl daemon-reload
systemctl restart docker
5、未完待续待更新…