我在使用docker-compose postgreSQL时遇到了问题,我正在使用Windows WSL 2 + Docker Desktop。当我在Linux服务器上运行docker-compose时,它可以正常工作,但是当我尝试在本地启动它时,我会收到以下错误:
postgres | chmod: changing permissions of '/var/lib/postgresql/data': Operation not permitted
ngnix | 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
postgres | The files belonging to this database system will be owned by user "postgres".
postgres | This user must also own the server process.
postgres |
postgres | The database cluster will be initialized with locale "en_US.utf8".
postgres | The default database encoding has accordingly been set to "UTF8".
postgres | The default text search configuration will be set to "english".
postgres |
postgres | Data page checksums are disabled.
postgres |
ngnix | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
ngnix | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
postgres | fixing permissions on existing directory /var/lib/postgresql/data ... initdb: error: could not change permissions of directory "/var/lib/postgresql/data": Operation not permitted
ngnix | /docker-entrypoint.sh: Configuration complete; ready for start up
postgres exited with code 1
我尝试像这样更改所有项目的权限 => chmod 777 -R project_folder
Dcoker-compose.yml:
postgresdb:
container_name: postgres
build:
context: ./docker/postgres
dockerfile: Dockerfile
environment:
- POSTGRES_PASSWORD=password123
volumes:
- ./docker/postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
- ./postgres-data:/var/lib/postgresql/data
ports:
- "5432:5432"
我不知道该如何解决它。请帮帮我!