Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set locale in Docker Alpine?

I can set locale with CentOS image with

FROM centos

ENV LANG en_US.UTF-8

ENV LC_ALL en_US.UTF-8

But It seems not work with Alpine image. How can I set locale with Alpine image?

like image 383
Kevin Avatar asked Mar 01 '18 03:03

Kevin


People also ask

What does locale GEN do?

locale-gen generates (or rather compiles) the "locale information" I mentioned above, by invoking localedef . The locale information is present in a textual format, which is easy to edit but hard to read for software (just like software source code).


1 Answers

It works for me, Dockerfile:

FROM openjdk:8-jdk-alpine

RUN apk update
RUN apk add tzdata
RUN cp /usr/share/zoneinfo/America/Sao_Paulo /etc/localtime
RUN rm -r /usr/share/zoneinfo/Africa && \
    rm -r /usr/share/zoneinfo/Antarctica && \
    rm -r /usr/share/zoneinfo/Arctic && \
    rm -r /usr/share/zoneinfo/Asia && \
    rm -r /usr/share/zoneinfo/Atlantic && \
    rm -r /usr/share/zoneinfo/Australia && \
    rm -r /usr/share/zoneinfo/Europe  && \
    rm -r /usr/share/zoneinfo/Indian && \
    rm -r /usr/share/zoneinfo/Mexico && \
    rm -r /usr/share/zoneinfo/Pacific && \
    rm -r /usr/share/zoneinfo/Chile && \
    rm -r /usr/share/zoneinfo/Canada
RUN echo "America/Sao_Paulo" >  /etc/timezone

ENV TZ America/Sao_Paulo
ENV LANG pt_BR.UTF-8
ENV LANGUAGE pt_BR.UTF-8
ENV LC_ALL pt_BR.UTF-8

ARG JAR_FILE
ADD ${JAR_FILE} /app/
RUN mv /app/${JAR_FILE} /app/app.jar
ENTRYPOINT java $JAVA_OPTS -jar /app/app.jar
like image 107
rafambbr Avatar answered Oct 03 '22 01:10

rafambbr