创建目录结构
/opt/admin
/bin
/docker
/libs
/logs
配置启动脚本/bin/start.sh
#!/bin/bash
# 停止容器
docker stop admin
echo "停止容器success!"
# 移除容器
docker rm admin
echo "移除容器success!"
# 移除镜像
docker rmi admin
echo "移除镜像success!"
# 制作镜像
docker build -t admin /opt/admin/docker/
echo "制作镜像success!"
# 支持字体,系统时间:解决海报问题
docker run -d --name admin -p 8080:8080 -v /opt/admin/logs/:/root/logs/ -v /usr/share/fonts/:/usr/share/fonts/ -v /etc/localtime:/etc/localtime admin admin:latest
echo "启动success!"
安装字体
yum -y install fontconfig
fc-cache --forc
配置/docker/Dockerfile
FROM dragonwell:8
ADD ./libs/admin.jar /root/admin.jar
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo "Asia/Shanghai" > /etc/timezone
EXPOSE 8080
WORKDIR /root
ENTRYPOINT ["java", "-Dspring.profiles.active=dev","-jar","admin.jar"]