问题
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?
回答1:
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
回答2:
There is a cleaner way using apk del tzdata
, described here:
Setting the timezone - Alpine Linux
来源:https://stackoverflow.com/questions/49042223/how-to-set-locale-in-docker-alpine