Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 991
Silver Flash Avatar asked Dec 31 '22 19:12

Silver Flash


1 Answers

Okay. looks like problem appears when you try to run pgadmin service.

This part

  ### 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

As you can see you trying to mount local directory ${DATA_PATH_HOST}/pgadmin into container's /var/lib/pgadmin

    volumes:
      - ${DATA_PATH_HOST}/pgadmin:/var/lib/pgadmin

As you can read in this article your local ${DATA_PATH_HOST}/pgadmin directory's UID and GID must be 5050. Is this 5050?

You can check it by running

ls -l ${DATA_PATH_HOST}

Output will be like

drwxrwxr-x 1 5050 5050 12693 Nov 11 14:56 pgadmin

or

drwxrwxr-x 1 SOME_USER SOME_GROUP 12693 Nov 11 14:56 pgadmin

if SOME_USER's and SOME_GROUP's IDs are 5050, it is okay. 5050 as is also okay. If not, try to do as described in article above.

sudo chown -R 5050:5050 ${DATA_PATH_HOST}/pgadmin

Also you need to check is environment variable exists:

# run it as same user as you running docker-compose
echo ${DATA_PATH_HOST}

If output will be empty you need to set ${DATA_PATH_HOST} or allow docker to read variables from file. There are many ways to do it.

like image 152
rzlvmp Avatar answered Jan 07 '23 14:01

rzlvmp