[英]Error starting postgres container - mkdir: Permission denied
I am starting a postgres container using following docker-compose.yml我正在使用以下 docker-compose.yml 启动一个 postgres 容器
version: '3'
services:
db:
image: postgres:latest
container_name: postgres
environment:
POSTGRES_USER: usr
POSTGRES_PASSWORD: pswd
POSTGRES_DB: db
PGDATA: /var/lib/postgresql/data/pgdata
ports:
- 5432:5432
volumes:
- nfs_cur_dir:/var/lib/postgresql/data
volumes:
nfs_cur_dir:
driver: local
driver_opts:
type: nfs
o: "addr=10.15.187.88,rw"
device: ":/u/uname/home/database"
I am getting following error when starting the container启动容器时出现以下错误
$sudo ./docker-compose up db
Starting postgres ... done
Attaching to postgres
postgres | mkdir: cannot create directory ‘/var/lib/postgresql/data’: Permission denied
postgres exited with code 1
The permissions on database
directory are 777 database
目录的权限为 777
drwxrwxrwx 3 uname grpname 4096 May 5 22:57 database
After the failure I also see pgdata
directory created as this -失败后,我还看到这样创建的
pgdata
目录 -
drwx------ 2 polkitd root 4096 May 5 22:57 pgdata
Note:笔记:
You should check the permissions that NFS share exposes.您应该检查 NFS 共享公开的权限。 According to what you said, if you use a local drive it works fine.
根据您的说法,如果您使用本地驱动器,它可以正常工作。 That's why I think the NFS share's permissions aren't working as you expect.
这就是为什么我认为 NFS 共享的权限没有按预期工作的原因。 Maybe you should create the directory before trying to run your application.
也许您应该在尝试运行应用程序之前创建目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.