I try to connect to Postgres inside a docker container
as a result, I received Invalid value for parameter "TimeZone": "Europe/Kyiv"
I’ve tried to add serverTimezone=Europe/Kyiv to the connect URL but its doest not work
jdbc:postgresql://localhost:5433/db_name?serverTimezone=Europe/Kyiv
Also, I’ve tried
SET time zone 'Europe/Kyiv"
UPD:
My docker compose file
services:
postgres:
container_name: postgres
image: postgres
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
PGDATA: /data/postgres
PGTZ: 'Europe/Kyiv'
TZ: 'Europe/Kyiv'
# PGTZ: 'Europe/Kiev'
# TZ: 'Europe/Kiev'
#
# PGTZ: 'GMT+2'
# TZ: 'GMT+2'
volumes:
- postgres:/data/postgres
ports:
- "5433:5432"
networks:
- postgres
restart: unless-stopped
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL}
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD}
PGADMIN_CONFIG_SERVER_MODE: 'False'
volumes:
- pgadmin:/var/lib/pgadmin
ports:
- "5050:80"
networks:
- postgres
restart: unless-stopped
networks:
postgres:
driver: bridge
volumes:
postgres:
pgadmin:
2
Answers
Solution - I've changed time zone on my OS to UTC
Have you tried setting timezone as environment variable?
When using
docker-compose
or when using
docker run
Reference