问题

跑 java 程序,日志中文乱码情况。
image.png

解决

安装相关包,地址:https://github.com/sgerrand/alpine-pkg-glibc/tree/2.31-r0

dockerfile 参考如下:

  1. ## Alpine 安装 Glibc https://github.com/sgerrand/alpine-pkg-glibc
  2. RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
  3. RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-2.31-r0.apk
  4. RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-bin-2.31-r0.apk
  5. RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.31-r0/glibc-i18n-2.31-r0.apk
  6. RUN apk add glibc-2.31-r0.apk
  7. RUN apk add glibc-bin-2.31-r0.apk
  8. RUN apk add glibc-i18n-2.31-r0.apk
  9. ## 编码问题
  10. RUN /usr/glibc-compat/bin/localedef -i en_US -f UTF-8 en_US.UTF-8
  11. ENV LANG=en_US.UTF-8
  12. ENV LANGUAGE=en_US.UTF-8

解决后:

image.png