docker 参数“时区”的值无效:“欧洲/基辅”Postgres

u5rb5r59  于 2023-03-07  发布在  Docker
关注(0)|答案(2)|浏览(264)

我尝试连接到Docker容器中的Postgres
结果,我收到了Invalid value for parameter "TimeZone": "Europe/Kyiv"
我试过将serverTimezone=Europe/基辅添加到连接URL,但它不起作用

jdbc:postgresql://localhost:5433/db_name?serverTimezone=Europe/Kyiv

而且我试过

SET time zone 'Europe/Kyiv"

**UPD:**我的Docker合成文件

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:
zzzyeukh

zzzyeukh1#

您是否尝试过将timezone设置为环境变量?
使用docker-compose

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

或使用docker run

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

Reference

8ehkhllq

8ehkhllq2#

解决方案-我已将操作系统上的时区更改为UTC

相关问题