docker openjdk部署拥有验证码的项目报NullPointerException

出错如下:

java.lang.NullPointerException: null
	at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264) ~[na:1.8.0_111-internal]
	at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219) ~[na:1.8.0_111-internal]
	at sun.awt.FontConfiguration.init(FontConfiguration.java:107) ~[na:1.8.0_111-internal]
	at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774) ~[na:1.8.0_111-internal]
	at sun.font.SunFontManager$2.run(SunFontManager.java:431) ~[na:1.8.0_111-internal]
	at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_111-internal]
	at sun.font.SunFontManager.<init>(SunFontManager.java:376) ~[na:1.8.0_111-internal]

出错原因:
一般的openjdk由于awt包缺少了某些东西,导致的报错

解决措施:
1)创建一个Dockerfile文件放到/home/dockerfile文件夹下,

FROM java:8-jre-alpine
RUN echo -e "https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/main\n\
https://mirror.tuna.tsinghua.edu.cn/alpine/v3.4/community" > /etc/apk/repositories

RUN apk --update add curl bash ttf-dejavu && \
      rm -rf /var/cache/apk/*

2)然后到/home/dockerfile目录下执行

docker build -t docker.io/java-font:8-jre-alpine .

你可能感兴趣的:(构建工具,docker)