GoogleContainerTools / distroless

🥑 Language focused docker images, minus the operating system.
Apache License 2.0
18.91k stars 1.16k forks source link

distroless/java and filename encoding to UTF-8 #737

Open npierot06 opened 3 years ago

npierot06 commented 3 years ago

Hello all, It seems that in the latest distroless/java:11, the sun.jnu.encoding is back to ANSI_X3.4-1968 instead of UTF-8 when using LANG=C.UTF-8

I tried 3 different images :

Fo now I can deal with the working sha256, but it would be great if the same fix done for https://github.com/GoogleContainerTools/distroless/issues/253 would be applied in future releases

Here is a test case to reproduce test.zip docker build -t test . && docker run --rm test

Thanks for all

npierot06 commented 3 years ago

Hi again, maybe zip file is not appropiated here :)

here are the files : A.java :

public class A { public static void main(String... args) { System.out.println("file.encoding=" + System.getProperty("file.encoding")); System.out.println("sun.jnu.encoding=" + System.getProperty("sun.jnu.encoding")); System.out.println("java.version=" + System.getProperty("java.version")); System.out.println("LANG=" + System.getenv("LANG")); System.out.println("\u65E5"); } }

Dockerfile :

FROM gcr.io/distroless/java:11

FROM gcr.io/distroless/java@sha256:2d96a9a913bf3923f504dca3e91260371591bac0e679d30a9ab19cece86dcf25

FROM gcr.io/distroless/java@sha256:f87dc3f7de32c36b77a0b50c3f8e4e9d76e846d26fb9287ea69512e4f5b7127d -- OK but to huge

FROM gcr.io/distroless/java@sha256:d9cceee40b4ffa4418793fad0400948205ed59fd24df4740ba6fa74562eff16f -- OK

COPY --from=debian:9.11 /usr/lib/locale /usr/lib/locale ENV LANG=C.UTF-8 COPY A.java /A.java ENTRYPOINT ["java", "-Dfile.encoding=UTF-8", "/A.java"]

Thanks