运行 docker-与dpage/pgadmin4图像合成时获取权限异常
Getting permission exception when run docker-compose up with dpage/pgadmin4 image
我正在尝试使用 pgadmin4 构建一个 ruby rails docker-compose postgreSQL 数据库,但不断从容器中获取权限异常。甚至/bin/sh在容器returns中也是一样的错误。
我正在使用 Ubuntu 18.04.3 LTS
完整日志
db_1 |
db_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1 |
db_1 | LOG: database system was shut down at 2020-02-05 07:15:13 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: autovacuum launcher started
db_1 | LOG: database system is ready to accept connections
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Starting gunicorn 19.9.0
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Using worker: threads
pgadmin_1 | [2020-02-05 07:15:17 +0000] [13] [INFO] Booting worker with pid: 13
pgadmin_1 | [2020-02-05 07:15:17 +0000] [13] [ERROR] Exception in worker process
pgadmin_1 | Traceback (most recent call last):
pgadmin_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
pgadmin_1 | worker.init_process()
pgadmin_1 | File "/usr/local/lib/python3.7/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.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
pgadmin_1 | self.load_wsgi()
pgadmin_1 | File "/usr/local/lib/python3.7/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.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
pgadmin_1 | self.callable = self.load()
pgadmin_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
pgadmin_1 | return self.load_wsgiapp()
pgadmin_1 | File "/usr/local/lib/python3.7/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.7/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 109, in <module>
pgadmin_1 | app = create_app()
pgadmin_1 | File "/pgadmin4/pgadmin/__init__.py", line 350, in create_app
pgadmin_1 | paths.init_app(app)
pgadmin_1 | File "/pgadmin4/pgadmin/utils/paths.py", line 92, in init_app
pgadmin_1 | 'The user does not have permission to read and write to the '
pgadmin_1 | Exception: The user does not have permission to read and write to the specified storage directory.
pgadmin_1 | [2020-02-05 07:15:17 +0000] [13] [INFO] Worker exiting (pid: 13)
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Shutting down: Master
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Reason: Worker failed to boot.
***_pgadmin_1 exited with code 3
docker-compose.yml 文件
version: '3'
services:
db:
image: postgres:9.5
volumes:
- postgres:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
volumes:
- pgadmin:/var/lib/pgadmin/storage
ports:
- '3030:80'
environment:
PGADMIN_DEFAULT_EMAIL: 'admin'
PGADMIN_DEFAULT_PASSWORD: password
depends_on:
- db
volumes:
postgres:
pgadmin:
(ruby rails 服务已删除,因为我认为它不相关)
修改 pgadmin 容器中的卷允许我在容器中使用 /bin/sh,但我不能使用任何命令
我遇到了与图像 dpage/pgadmin4:4.18 相同的问题。挖了一下,无论出于什么原因,pgadmin 都没有 运行 在服务器模式下,这导致它使用无法通过权限检查的不同目录。
为了解决这个问题,我添加了一个 PGADMIN_CONFIG_SERVER_MODE 环境变量并将其设置为 True。在您的情况下,您将向 docker-compose.yml 添加另一个环境变量,内容为:
PGADMIN_CONFIG_SERVER_MODE: True
首字母大写非常重要。该行被转换为 Python 代码(SERVER_MODE = True in config_distro.py 对于那些想知道的人),如果 'T' 没有大写,它将失败。
我遇到了同样的问题。我可以通过将卷安装在稍微不同的位置来解决它:
volumes:
- pgadmin:/var/lib/pgadmin4/storage
请注意,在您的脚本中,它安装在 /var/lib/pgadmin/storage
。
尝试删除并重新创建 Docker 卷,因此
docker volume ls
找到卷名,后面是
docker volume rm <volume name>
这将重新创建可能导致问题的卷
我正在尝试使用 pgadmin4 构建一个 ruby rails docker-compose postgreSQL 数据库,但不断从容器中获取权限异常。甚至/bin/sh在容器returns中也是一样的错误。
我正在使用 Ubuntu 18.04.3 LTS
完整日志
db_1 |
db_1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
db_1 |
db_1 | LOG: database system was shut down at 2020-02-05 07:15:13 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: autovacuum launcher started
db_1 | LOG: database system is ready to accept connections
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Starting gunicorn 19.9.0
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Listening at: http://[::]:80 (1)
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Using worker: threads
pgadmin_1 | [2020-02-05 07:15:17 +0000] [13] [INFO] Booting worker with pid: 13
pgadmin_1 | [2020-02-05 07:15:17 +0000] [13] [ERROR] Exception in worker process
pgadmin_1 | Traceback (most recent call last):
pgadmin_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
pgadmin_1 | worker.init_process()
pgadmin_1 | File "/usr/local/lib/python3.7/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.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
pgadmin_1 | self.load_wsgi()
pgadmin_1 | File "/usr/local/lib/python3.7/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.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
pgadmin_1 | self.callable = self.load()
pgadmin_1 | File "/usr/local/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
pgadmin_1 | return self.load_wsgiapp()
pgadmin_1 | File "/usr/local/lib/python3.7/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.7/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 109, in <module>
pgadmin_1 | app = create_app()
pgadmin_1 | File "/pgadmin4/pgadmin/__init__.py", line 350, in create_app
pgadmin_1 | paths.init_app(app)
pgadmin_1 | File "/pgadmin4/pgadmin/utils/paths.py", line 92, in init_app
pgadmin_1 | 'The user does not have permission to read and write to the '
pgadmin_1 | Exception: The user does not have permission to read and write to the specified storage directory.
pgadmin_1 | [2020-02-05 07:15:17 +0000] [13] [INFO] Worker exiting (pid: 13)
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Shutting down: Master
pgadmin_1 | [2020-02-05 07:15:17 +0000] [1] [INFO] Reason: Worker failed to boot.
***_pgadmin_1 exited with code 3
docker-compose.yml 文件
version: '3'
services:
db:
image: postgres:9.5
volumes:
- postgres:/var/lib/postgresql/data
pgadmin:
image: dpage/pgadmin4
volumes:
- pgadmin:/var/lib/pgadmin/storage
ports:
- '3030:80'
environment:
PGADMIN_DEFAULT_EMAIL: 'admin'
PGADMIN_DEFAULT_PASSWORD: password
depends_on:
- db
volumes:
postgres:
pgadmin:
(ruby rails 服务已删除,因为我认为它不相关)
修改 pgadmin 容器中的卷允许我在容器中使用 /bin/sh,但我不能使用任何命令
我遇到了与图像 dpage/pgadmin4:4.18 相同的问题。挖了一下,无论出于什么原因,pgadmin 都没有 运行 在服务器模式下,这导致它使用无法通过权限检查的不同目录。
为了解决这个问题,我添加了一个 PGADMIN_CONFIG_SERVER_MODE 环境变量并将其设置为 True。在您的情况下,您将向 docker-compose.yml 添加另一个环境变量,内容为:
PGADMIN_CONFIG_SERVER_MODE: True
首字母大写非常重要。该行被转换为 Python 代码(SERVER_MODE = True in config_distro.py 对于那些想知道的人),如果 'T' 没有大写,它将失败。
我遇到了同样的问题。我可以通过将卷安装在稍微不同的位置来解决它:
volumes:
- pgadmin:/var/lib/pgadmin4/storage
请注意,在您的脚本中,它安装在 /var/lib/pgadmin/storage
。
尝试删除并重新创建 Docker 卷,因此
docker volume ls
找到卷名,后面是
docker volume rm <volume name>
这将重新创建可能导致问题的卷