skip to Main Content

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


  1. Chosen as BEST ANSWER

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


  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search