权限被拒绝:Docker 中的“/var/lib/pgadmin/sessions" [英] Permission denied: '/var/lib/pgadmin/sessions' in Docker
问题描述
我遇到了这个帖子中描述的相同问题,但在 docker 容器内.我真的不知道我的 pgadmin 文件驻留在哪里来编辑它的默认路径.我该如何解决这个问题?请尽可能详细,因为我不知道如何 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.
这里是docker-compose up
命令的逐字摘要:
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
我的 docker-compose.yml:
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
推荐答案
好的.当您尝试运行 pgadmin
服务时似乎出现问题.
Okay. looks like problem appears when you try to run pgadmin
service.
这部分
### 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
如您所见,您尝试将本地目录 ${DATA_PATH_HOST}/pgadmin
挂载到容器的 /var/lib/pgadmin
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
正如您在这篇 文章中看到的那样 你的本地 ${DATA_PATH_HOST}/pgadmin
目录的 UID 和 GID 必须是 5050
.这是5050
吗?
As you can read in this article your local ${DATA_PATH_HOST}/pgadmin
directory's UID and GID must be 5050
. Is this 5050
?
可以通过运行查看
ls -l ${DATA_PATH_HOST}
输出会是这样的
drwxrwxr-x 1 5050 5050 12693 Nov 11 14:56 pgadmin
或
drwxrwxr-x 1 SOME_USER SOME_GROUP 12693 Nov 11 14:56 pgadmin
如果 SOME_USER
和 SOME_GROUP
的 ID 是 5050
,没关系.5050
一样也可以.如果没有,请尝试按照上面文章中的说明进行操作.
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}
如果输出为空,您需要设置 ${DATA_PATH_HOST}
或允许 docker 从文件中读取变量.有很多方法可以做到.
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.
这篇关于权限被拒绝:Docker 中的“/var/lib/pgadmin/sessions"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!