1

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 Answers2

1

Solution - I've changed time zone on my OS to UTC

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 11 '23 at 00:24
0

Have you tried setting timezone as environment variable?

When using docker-compose

postgres:
    image: postgres
    environment:
        TZ: 'Europe/Kyiv'
        PGTZ: 'Europe/Kyiv'

or when using docker run

docker run .... --env TZ=Europe/Kyiv --env PGTZ=Europe/Kyiv ....

Reference

  • I've tried this but it's not working I had the same error I've updated question (I've added my docker-compose file) – Black Rabbit Mar 06 '23 at 13:25