Michael
Michael

Reputation: 869

How to Change Default import/export Directory in Pgadmin4 Docker Image

I'm using this docker-compose.yml file to build:

version: '3.8'
services:
  db:
    container_name: pg_container
    image: postgres
    restart: always
    volumes:
      - $HOME/docker/volumes/postgres:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: test
      POSTGRES_PASSWORD: test
      POSTGRES_DB: test_db
    ports:
      - "5432:5432"
  pgadmin:
    container_name: pgadmin4_container
    image: dpage/pgadmin4
    restart: always
#    volumes:
#      - $HOME/docker/volumes/imports:/var/lib/pgadmin/storage
    environment:
      PGADMIN_DEFAULT_EMAIL: [email protected]
      PGADMIN_DEFAULT_PASSWORD: root
    ports:
      - "5050:80"

It works great except that when I try to use the import/export tool in Pgadmin4 it only allows me to be in one directory. After a bit of research I have tracked it down to the /var/lib/pgadmin/storage/admin_admin.com directory. My thought was that I could mount it to a local directory so that I could modify files quickly and try to reimport when an import fails. However when I uncomment the lines for the mount I get permission errors.

I have tried going into the Pgadmin4 container and modifying the file permissions on /var/lib/pgadmin/storage, but I can't figure out the root password. I think I may be missing something simple.

Does anyone know how to modify the file permission on /var/lib/pgadmin/storage so that I can mount it to a directory on the host? Or where I would change the default for where the Pgadmin4 import/export tool looks for files?

Upvotes: 3

Views: 2567

Answers (1)

IvanP
IvanP

Reputation: 139

I am not sure whether you really need to change default import/export directory to address that permission issue. I think it may be related to the read-write rights of the host directory. Pgadmin documentation writes:

Warning: pgAdmin runs as the pgadmin user (UID: 5050) in the pgadmin group (GID: 5050) in the container. You must ensure that all files are readable, and where necessary (e.g. the working/session directory) writeable for this user on the host machine. For example:

sudo chown -R 5050:5050 <host_directory>

In your case the host_directory would be $HOME/docker/volumes/imports.

Worth mentioning that permissions issue on the host directory may sometimes result in the pgAdmin container starting regularly, without the server being actually reachable, which translate in a never ending loading phase of the tab in the web browser.

P.S. I’m noticing now that the question is months old so I’m assuming you have already solved the issue. Hope this will be helpful for others stumbling across that same problem.

Upvotes: 0

Related Questions