sunjdk中文字体镜像创建过程
目前假设在Linux的/root/dockerfile目录下
创建目录用于存放制作镜像的文件
mkdir java-fonts
准备中文字体文件
这里我只准备了宋体simsun.ttc,可以在windows字体中获取。
mkdir java-fonts/chinese
cp /xxx/simsun.ttc ./java-fonts/chinese
创建dockerfile
FROM alpine
MAINTAINER Allen <ftwc31@163.com>
ENV TIME_ZONE Asia/Shanghai
RUN echo '@aliyun http://mirrors.aliyun.com/alpine/edge/community' > /etc/apk/repositories && \
echo 'http://mirrors.aliyun.com/alpine/v3.7/main/' >> /etc/apk/repositories && \
echo 'http://mirrors.aliyun.com/alpine/v3.7/community/' >> /etc/apk/repositories && \
apk update && \
apk upgrade && \
apk add curl ca-certificates openjdk8@aliyun openjdk8-jre-base@aliyun openjdk8-jre@aliyun openjdk8-jre-lib@aliyun && \
apk del ca-certificates && \
apk add --update ttf-dejavu fontconfig && \
apk add --no-cache tzdata && \
rm -rf /tmp/* /var/cache/apk/*
RUN echo "${TIME_ZONE}" >etc/timezone && \
ln -sf /usr/share/zoneinfo/${TIME_ZONE} /etc/localtime
ENV LANG zh_CN.UTF-8
ENV LANGUAGE zh_CN:zh
ENV LC_ALL zh_CN.UTF-8
LABEL JDK_VERSION=openjdk8.161.12-r0
COPY chinese /usr/share/fonts/chinese
CMD ["java","-version"]
构建镜像并推送
- 镜像构建命令,docker build -t java:font-chinese java-fonts/
- 镜像tag, docker tag 29103f827fd5 registry.cn-beijing.aliyuncs.com/klx/sunjdk:fonts-chinese
- 推送到阿里云容器仓库,docker push registry.cn-beijing.aliyuncs.com/klx/sunjdk:fonts-chinese