I'm been running postgres as a Docker Container for quite awhile. Initially, the TZ and PGTZ were not set, so I think it was defaulting to UTC. On my dev system I tried the following in docker-compose.yml:
postgres:
image: postgres:13
ports: ["5557:5432"]
restart: unless-stopped
volumes:
- ./Index:/var/lib/postgresql/data
environment:
TZ: "America/Cayman"
PGTZ: "America/Cayman"
POSTGRES_PASSWORD: "postgres"
and that seems to make the adjustment to the local timezone. I have not deployed that to a live system because I'm wondering if that will mess up anything in regards to DB transaction history and log files, etc. The DB integrity is fine now, and I have backup going back quite a ways. I'm not sure that it is even really necessary to set the timezone, but kind of nice to have all of the containers set to the local zone rather than UTC.
The other issue is unrelated, and sort of mentioned here: WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
Briefly:
That Database Index is mapped to a Folder on the host in the root of the Docker Package, and everything else seems to work fine as far as the database is concerned. I am using a Mac, but if I list permission from CLI for the DB folder I get:
-rw-------@ 1 sscotti staff 3 Feb 22 11:01 PG_VERSION
drwx------@ 6 sscotti staff 192 Feb 22 11:54 base
drwx------@ 60 sscotti staff 1920 Feb 22 16:00 global
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_commit_ts
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_dynshmem
-rw-------@ 1 sscotti staff 4782 Feb 22 11:02 pg_hba.conf
-rw-------@ 1 sscotti staff 1636 Feb 22 11:01 pg_ident.conf
drwx------@ 5 sscotti staff 160 Feb 22 17:46 pg_logical
drwx------@ 4 sscotti staff 128 Feb 22 11:01 pg_multixact
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_notify
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_replslot
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_serial
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_snapshots
drwx------@ 2 sscotti staff 64 Feb 22 16:00 pg_stat
drwx------@ 5 sscotti staff 160 Feb 22 17:50 pg_stat_tmp
drwx------@ 3 sscotti staff 96 Feb 22 11:01 pg_subtrans
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_tblspc
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_twophase
drwx------@ 4 sscotti staff 128 Feb 22 11:01 pg_wal
drwx------@ 3 sscotti staff 96 Feb 22 11:01 pg_xact
-rw-------@ 1 sscotti staff 88 Feb 22 11:01 postgresql.auto.conf
-rw-------@ 1 sscotti staff 28073 Feb 22 11:01 postgresql.conf
-rw-------@ 1 sscotti staff 36 Feb 22 16:00 postmaster.opts
-rw------- 1 sscotti staff 94 Feb 22 16:00 postmaster.pid
pg_stat folder is actually empty.
and pg_stat_temp has:
-rw------- 1 sscotti staff 1952 Feb 22 17:54 db_0.stat
-rw------- 1 sscotti staff 20360 Feb 22 17:54 db_13395.stat
-rw------- 1 sscotti staff 1151 Feb 22 17:54 global.stat
The issue seems to be that the DB files are bound to a local folder on the host rather than to a Docker Volume. It is much more convenient to have it bound to a local folder easily accessible from the host, but I think there are some permissions issues related to that. I might actually want to change to a volume, but the volume still has to be persistent and easily backed up to a local NAS or Cloud service that we use for backup.
With Docker Desktop for MacOS, there does seem to be a bit of a performance hit using bound folders rather than volumes, but on LINUX it doesn't seem to cause a problem, although the "statistics file" warning occurs there also.
Thanks.