'Permission denied: '/var/lib/pgadmin/sessions' in Docker

I have got the same problem described in this post, but inside a docker container. I don't really know where my pgadmin file reside to edit it's default path.How do I go about fixing this issue? Please be as detailed as possible because I don't know how to docker.

Here is an abstract of the verbatim of docker-compose up command:

php-worker_1  | 2020-11-11 05:50:13,700 INFO spawned: 'laravel-worker_03' with pid 67
pgadmin_1     | [2020-11-11 05:50:13 +0000] [223] [INFO] Worker exiting (pid: 223)
pgadmin_1     | WARNING: Failed to set ACL on the directory containing the configuration database:
pgadmin_1     |            [Errno 1] Operation not permitted: '/var/lib/pgadmin'
pgadmin_1     | HINT   : You may need to manually set the permissions on
pgadmin_1     |          /var/lib/pgadmin to allow pgadmin to write to it.
pgadmin_1     | ERROR  : Failed to create the directory /var/lib/pgadmin/sessions:
pgadmin_1     |            [Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
pgadmin_1     | HINT   : Create the directory /var/lib/pgadmin/sessions, ensure it is writeable by
pgadmin_1     |          'pgadmin', and try again, or, create a config_local.py file
pgadmin_1     |          and override the SESSION_DB_PATH setting per
pgadmin_1     |          https://www.pgadmin.org/docs/pgadmin4/4.27/config_py.html
pgadmin_1     | /usr/local/lib/python3.8/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
pgadmin_1     |   return io.open(fd, *args, **kwargs)
pgadmin_1     | [2020-11-11 05:50:13 +0000] [224] [INFO] Booting worker with pid: 224

my docker-compose.yml:

  ### pgAdmin ##############################################
  pgadmin:
    image: dpage/pgadmin4:latest
    environment:
      - "PGADMIN_DEFAULT_EMAIL=${PGADMIN_DEFAULT_EMAIL}"
      - "PGADMIN_DEFAULT_PASSWORD=${PGADMIN_DEFAULT_PASSWORD}"
    ports:
      - "${PGADMIN_PORT}:80"
    volumes:
      - ${DATA_PATH_HOST}/pgadmin:/var/lib/pgadmin
    depends_on:
      - postgres
    networks:
      - frontend
      - backend


Solution 1:[1]

If you're on Windows, add this line to your docker-compose.yml. It gives container an access to your local folder

version: "3.9"
services:
  postgres:
    user: root  <- this one 
    container_name: postgres_container
    image: postgres:14.2 

Solution 2:[2]

When running in kubernetes environment, I had to add these values.

   spec:
     containers:
       - name: pgadmin
         image: dpage/pgadmin4:5.4
         securityContext:
           runAsUser: 0
           runAsGroup: 0

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 osynavets
Solution 2 bhargav joshi