I'm trying to set a localtime to my docker container as the same as my localtime locally to use on a spring-boot application when save a data.
spring-boot app:
...
cpoWorkflowExecution.setStartDate(LocalDateTime.now());
...
Local localtime:
[ainacio@brsp1nf01 cpo-dockers]$ ls -l /etc/localtime
lrwxrwxrwx. 1 root root 39 Oct 6 07:42 /etc/localtime -> ../usr/share/zoneinfo/America/Sao_Paulo
Local timezone:
[ainacio@brsp1nf01 cpo-dockers]$ cat /etc/timezone
America/Sao_Paulo
Container localtime didn't work:
root@ffbd68eeaccd:/# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 27 Nov 17 13:37 /etc/localtime -> /usr/share/zoneinfo/Etc/UTC
Container timezone worked:
root@ffbd68eeaccd:/# cat /etc/timezone
America/Sao_Paulo
Docker-compose:
version: '3'
services:
cpo-executor:
container_name: cpo-executor
image: .../cpo-executor:1.103.3.1
ports:
- 8879:8879
environment:
- TZ=America/Sao_Paulo
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
networks:
- cpo-network
depends_on:
- cpo-config-server
I've also tried to set TZ environment variable but it didn't work as well.
I'm generating the docker image using spring-boot maven plugin:
mvn spring-boot:build-image -DskipTests -Dspring-boot.build-image.imageName=.../cpo-executor:1.103.3.1
What am I missing?