How to solve "Operation not permitted: '/var/lib/pgadmin'" error in laradock at Windows Subsystem for Linux?
Asked Answered
N

5

13

I am using the Laradock in my Laravel project for dockerizing with Nginx, Postgres, and Pgadmin. All the containers are running well but the Pgadmin is unable to do so. Here is my error log,

pgadmin_1              | WARNING: Failed to set ACL on the directory containing the configuration database: [Errno 1] Operation not permitted: '/var/lib/pgadmin'
pgadmin_1              | Traceback (most recent call last):
pgadmin_1              |   File "run_pgadmin.py", line 4, in <module>
pgadmin_1              |     from pgAdmin4 import app
pgadmin_1              |   File "/pgadmin4/pgAdmin4.py", line 92, in <module>
pgadmin_1              |     app = create_app()
pgadmin_1              |   File "/pgadmin4/pgadmin/__init__.py", line 241, in create_app
pgadmin_1              |     create_app_data_directory(config)
pgadmin_1              |   File "/pgadmin4/pgadmin/setup/data_directory.py", line 40, in create_app_data_directory
pgadmin_1              |     _create_directory_if_not_exists(config.SESSION_DB_PATH)
pgadmin_1              |   File "/pgadmin4/pgadmin/setup/data_directory.py", line 16, in _create_directory_if_not_exists
pgadmin_1              |     os.mkdir(_path)
pgadmin_1              | PermissionError: [Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
pgadmin_1              | sudo: setrlimit(RLIMIT_CORE): Operation not permitted
pgadmin_1              | [2020-06-07 11:48:43 +0000] [1] [INFO] Starting gunicorn 19.9.0
pgadmin_1              | [2020-06-07 11:48:43 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
pgadmin_1              | [2020-06-07 11:48:43 +0000] [1] [INFO] Using worker: threads
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-06-07 11:48:43 +0000] [83] [INFO] Booting worker with pid: 83
pgadmin_1              | [2020-06-07 11:48:44 +0000] [83] [ERROR] Exception in worker process
pgadmin_1              | Traceback (most recent call last):
pgadmin_1              |   File "/usr/local/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
pgadmin_1              |     worker.init_process()
pgadmin_1              |   File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/gthread.py", line 104, in init_process
pgadmin_1              |     super(ThreadWorker, self).init_process()
pgadmin_1              |   File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 129, in init_process
pgadmin_1              |     self.load_wsgi()
pgadmin_1              |   File "/usr/local/lib/python3.8/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
pgadmin_1              |     self.wsgi = self.app.wsgi()
pgadmin_1              |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
pgadmin_1              |     self.callable = self.load()
pgadmin_1              |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
pgadmin_1              |     return self.load_wsgiapp()
pgadmin_1              |   File "/usr/local/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
pgadmin_1              |     return util.import_app(self.app_uri)
pgadmin_1              |   File "/usr/local/lib/python3.8/site-packages/gunicorn/util.py", line 350, in import_app
pgadmin_1              |     __import__(module)
pgadmin_1              |   File "/pgadmin4/run_pgadmin.py", line 4, in <module>
pgadmin_1              |     from pgAdmin4 import app
pgadmin_1              |   File "/pgadmin4/pgAdmin4.py", line 92, in <module>
pgadmin_1              |     app = create_app()
pgadmin_1              |   File "/pgadmin4/pgadmin/__init__.py", line 241, in create_app
pgadmin_1              |     create_app_data_directory(config)
pgadmin_1              |   File "/pgadmin4/pgadmin/setup/data_directory.py", line 40, in create_app_data_directory
pgadmin_1              |     _create_directory_if_not_exists(config.SESSION_DB_PATH)
pgadmin_1              |   File "/pgadmin4/pgadmin/setup/data_directory.py", line 16, in _create_directory_if_not_exists
pgadmin_1              |     os.mkdir(_path)
pgadmin_1              | PermissionError: [Errno 13] Permission denied: '/var/lib/pgadmin/sessions'
pgadmin_1              | [2020-06-07 11:48:44 +0000] [83] [INFO] Worker exiting (pid: 83)
pgadmin_1              | WARNING: Failed to set ACL on the directory containing the configuration database: [Errno 1] Operation not permitted: '/var/lib/pgadmin'
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-06-07 11:48:44 +0000] [1] [INFO] Shutting down: Master
pgadmin_1              | [2020-06-07 11:48:44 +0000] [1] [INFO] Reason: Worker failed to boot.

I have tried many ways to solve this problem. Such as,

OSError: [Errno 13] Permission denied: '/var/lib/pgadmin'

https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html

and some other github issues and their solutions. I also run the sudo chmod -R 777 ~/.laradock/data/pgadmin and sudo chmod -R 777 /var/lib/pgadmin command to get the permission but still the same error log. Can you guys help me on this? I think some others are also getting this error on their local machine. Thanks πŸ™‚

Norvell answered 7/6, 2020 at 12:3 Comment(2)
Which docker command or docker compose file are you using to start the container? You may be mounting the a different directory – Eonian
What is the relation to StackOverflow? – Curative
M
8

You may try this:

sudo chown -R 5050:5050 ~/.laradock/data/pgadmin

Then restart the container. Cause in the container with:

uid=5050(pgadmin) gid=5050(pgadmin)

and

drwx------ 4 pgadmin  pgadmin  56 Jan 27 08:25 pgadmin
Motorman answered 27/1, 2021 at 8:33 Comment(1)
This solves the issue, but the directory mentioned is a personal one so remember to use the actual directory that is being mapped to /var/lib/pgadmin in your docker setup. – Popsicle
M
5

As others have noted above, I found that Permission denied: '/var/lib/pgadmin/sessions' in Docker speaks to the challenge on the persistent local folder not having the correct user permissions.

After running sudo chown -R 5050:5050 ~/.laradock/data/pgadmin and restarting the container, the below error is no longer in my log

PermissionError: [Errno 13] Permission denied:

Mcdaniel answered 29/1, 2021 at 4:41 Comment(1)
Hello and welcome to SO! Please read the tour, and How do I write a good answer? Try to elaborate how to solve this issue. – Marcie
V
3

A similar error happens when using Kubernetes and the pgadmin4 helm chart from https://github.com/rowanruseler/helm-charts.

The solution is to set:

VolumePermissions:
  enabled: true

even when persistence is not enabled. In this way also the /var/lib/pgadmin folder in the container gets assigned of the correct permissions and the pgadmin4.db database can be created correctly.

Vitality answered 6/12, 2021 at 17:9 Comment(0)
A
1

Assuming you have folder with pgadmin4.db already defined on your git repo with an other user than pgadmin, you can do so:

postgres_interface:
  image: dpage/pgadmin4
  environment:
    - [email protected]
    - PGADMIN_DEFAULT_PASSWORD=postgres
  ports:
    - "5050:80"
  user: root
  volumes:
    - ./env/local/pgadmin/pgadmin4.db:/pgadmin4.db
     entrypoint: /bin/sh -c "cp /pgadmin4.db /var/lib/pgadmin/pgadmin4.db && cd /pgadmin4 && /entrypoint.sh"
Ademption answered 14/12, 2021 at 15:34 Comment(1)
Don't forget to recreate the docker image using docker compose down followed by docker compose up (or docker-compose instead of docker compose if you're still using the old version) – Auction
C
-1

The only solution I can provide is to log in to the container with

docker-compose exec --user root pgadmin sh

and then

chmod 0777 /var/lib/pgadmin -R

probably it may be better to create your own dockerfile from dpage/pgadmin4 and run these commands in advance.

Chucho answered 8/9, 2020 at 8:40 Comment(0)

© 2022 - 2025 β€” McMap. All rights reserved.