0

I'm trying to change the timezone of my container into "Europe/paris", I saw I had to set TZ environment variable so I did this, but it doesn't change the timezone..

here's my Dockerfile :

FROM node:latest

RUN mkdir /pind

WORKDIR /pind


ENV TZ Europe/Paris
RUN apt update && apt install tzdata -y

ENV PRODUCTION="true"

COPY ./ ./

RUN npm install

CMD npm run start

and the output of the command date in my container : enter image description here

but the real time in Europe/Paris timezone is 16:21

patacoing
  • 87
  • 1
  • 10
  • CEST is the correct time zone, so your setting has worked. If you're running Windows and WSL2, then this might help: https://stackoverflow.com/questions/65086856/wsl2-clock-is-out-of-sync-with-windows. I had lots of issues with the clock on my machine when I ran WSL2. – Hans Kilian Apr 16 '22 at 14:31

1 Answers1

1

For an alpine based image you have to install the tzdata first. (see this issue here)

RUN apk add --no-cache tzdata
ENV TZ Europe/Paris
ahsan
  • 312
  • 1
  • 6
  • Did you read the question? In the dockerfile source: `ENV TZ Europe/Paris RUN apt update && apt install tzdata -y` .. and `apt` is the package-manager for Debian and derivatives (as `apk` is for Alpine). – hc_dev May 27 '22 at 15:28