Setup pgadmin docker@Synology

Create pgadmin.yml file with the following content:

services:
  pgadmin:
    container_name: pgadmin
    image: dpage/pgadmin4:latest
    user: 0:0
    mem_limit: 256m
    cpu_shares: 768
    restart: unless-stopped
    environment:
      - TZ=Asia/Singapore
      - PGADMIN_DEFAULT_EMAIL=<[email protected]>
      - PGADMIN_DEFAULT_PASSWORD=<my_pgadmin_password>
      - PGADMIN_CONFIG_ENHANCED_COOKIE_PROTECTION=True
      - PGADMIN_CONFIG_LOGIN_BANNER="Authorised users only!"
      - PGADMIN_CONFIG_CONSOLE_LOG_LEVEL=10
    ports:
      - 5431:80
    volumes:
      - /volume1/containers/pgadmin/data:/var/lib/pgadmin:rw
      - /volume1/containers/pgadmin/servers.json:/pgadmin4/servers.json
      - /etc/localtime:/etc/localtime:ro

Create the following directories

# mkdir -p /volume1/containers/pgadmin/{data,servers.json}

Update permission and change ownership (required if you are facing permission issues)

# synoacltool -addace /volume1/containers/pgadmin/data user:5050:allow:rwxpdDaARWc--:fd--

# chown -R 5050:5050 /volume1/containers/pgadmin/data

If you want to allow access to built-in postgres server

# vi /etc/postgresql/postgresql.conf

   Change listen_addresses = '127.0.0.1' to listen_addresses = '*'


# vi /etc/postgresql/pg_hba.conf
   Add new line for
      host    all             all             <your_container_ip>/32           trust

Restart postgres service
# sudo systemctl restart pgsql

Start pgadmin container

# docker compose -f pgadmin.yml up -d

Access pgadmin portal via http://localhost:5431 and login using the above username/password (as specified in your pgadmin.yml file)

About: author