so I am having exactly the same problem as @FletchNZ I installed postgresql using docker container, once installed I cannot access the directory /srv/docker/postgres. So I changed the owner to root for postgres and I still cannot access the folder. So I decided to chmod -R 757 postgres and then I was able to enter the postgres directory.
However after installing psotgres I cannot access my home assistant, glances, tasmota admin.
So I decided to delete the postgres directory and from portainer delete the container and image etc. Done a restart and I still cannot access HA etc. Checked the /srv/docker directory and I see postgres back again with the same ownership and accessing issues as described above. Therefore I reinstalled postgres using docker compose hoping that it would work and get HA etc back running but to no avail.
here is me before doing any changes :
bachoo786@nuc:/srv/docker$ ls -l
total 36
-rw-rw-rw- 1 root root 3038 Dec 15 16:33 docker-compose.yaml
drwxr-xr-x 2 bachoo786 bachoo786 4096 Dec 12 23:11 duckdns
drwxr-xr-x 2 root root 4096 Dec 15 16:09 glances
drwxrwxrwx 10 root root 4096 Dec 15 16:34 homeassistant
drwxr-xr-x 11 bachoo786 bachoo786 4096 Dec 13 22:16 letsencrypt
drwxr-xr-x 5 nobody root 4096 Dec 10 17:34 mosquitto
drwxrwxrwx 4 root root 4096 Dec 10 00:46 portainer
drwx------ 19 999 root 4096 Dec 15 16:34 postgres
drwxr-xr-x 4 root root 4096 Dec 14 16:03 tasmoadmin
and this is after allowing root to become the owner of postgres:
bachoo786@nuc:/srv/docker$ sudo chown root:root /srv/docker/postgres
bachoo786@nuc:/srv/docker$ ls -l
total 36
-rw-rw-rw- 1 root root 3038 Dec 15 16:33 docker-compose.yaml
drwxr-xr-x 2 bachoo786 bachoo786 4096 Dec 12 23:11 duckdns
drwxr-xr-x 2 root root 4096 Dec 15 16:09 glances
drwxrwxrwx 10 root root 4096 Dec 15 16:37 homeassistant
drwxr-xr-x 11 bachoo786 bachoo786 4096 Dec 13 22:16 letsencrypt
drwxr-xr-x 5 nobody root 4096 Dec 10 17:34 mosquitto
drwxrwxrwx 4 root root 4096 Dec 10 00:46 portainer
drwx------ 19 root root 4096 Dec 15 16:34 postgres
drwxr-xr-x 4 root root 4096 Dec 14 16:03 tasmoadmin
Here is my docker compose file:
postgres:
container_name: postgres
image: postgres
restart: unless-stopped
# network_mode: host
volumes:
- /srv/docker/postgres:/var/lib/postgresql/data
- /etc/localtime:/etc/localtime:ro
environment:
- POSTGRES_DB=homeassistant
- POSTGRES_USER=hass
- POSTGRES_PASSWORD=XXX
So I have been reading up this thread and see what @flamingm0e said. In my case the log from pg_hba.conf is the following:
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust
host all all all md5
I think its to do with ownership. When I checked the permissions for the postgres directory I have 999. Here it is:
bachoo786@nuc:/srv/docker/postgres$ ls -l
total 116
drwxr-xrwx 6 999 docker 4096 Dec 15 16:14 base
drwxr-xrwx 2 999 docker 4096 Dec 15 16:15 global
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_commit_ts
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_dynshmem
-rwxr-xrwx 1 999 docker 4535 Dec 15 16:14 pg_hba.conf
-rwxr-xrwx 1 999 docker 1636 Dec 15 16:14 pg_ident.conf
drwxr-xrwx 4 999 docker 4096 Dec 15 16:15 pg_logical
drwxr-xrwx 4 999 docker 4096 Dec 15 16:14 pg_multixact
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_notify
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_replslot
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_serial
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_snapshots
drwxr-xrwx 2 999 docker 4096 Dec 15 16:15 pg_stat
drwxr-xrwx 2 999 docker 4096 Dec 15 16:15 pg_stat_tmp
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_subtrans
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_tblspc
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_twophase
-rwxr-xrwx 1 999 docker 3 Dec 15 16:14 PG_VERSION
drwxr-xrwx 3 999 docker 4096 Dec 15 16:14 pg_wal
drwxr-xrwx 2 999 docker 4096 Dec 15 16:14 pg_xact
-rwxr-xrwx 1 999 docker 88 Dec 15 16:14 postgresql.auto.conf
-rwxr-xrwx 1 999 docker 23750 Dec 15 16:14 postgresql.conf
-rwxr-xrwx 1 999 docker 36 Dec 15 16:14 postmaster.opts
Can anyone please help me? @flamingm0e