Postgres in WSL 2 - : Operation not permitted when I share volumes enter windows folder.
I’m using Windows WSL2 Sub system to emulate Linux on a VM.
I’m having trouble sharing the linux volume to a folder that is on windows.
WSL sets up a c directory within mnt. It is this directory that I am trying to use to create the Docker volume.
The problem does not occur when I unmount the volume on file compose.
I believe it must be something with permission in the windows folder.
Thank you
version: "3.6"
services:
db:
image: "postgres:10"
container_name: "DB"
ports:
- "5432:5432"
volumes:
- "/mnt/c/Users/mar/src/data:/var/lib/postgresql/data"
environment:
POSTGRES_USER: "root"
POSTGRES_PASSWORD: "root"
POSTGRES_DB: "dev"
DB | chmod: changing permissions of ‘/var/lib/postgresql/data’: Operation not permitted DB exited with code 1
tekki
(Tekki)
April 11, 2020, 8:09am
2
I would never use a mounted Windows folder for the Postgres data. This is a completely different file system and many file attributes are missing.
tecvaldo
(Tecvaldo)
August 13, 2020, 7:09pm
3
Yes, this worked for me when working on windows. What I did was this:
version: '3.1'
services:
postgres:
image: postgres
restart: always
environment:
POSTGRES_PASSWORD: admin
volumes:
- postgres-vol:/var/lib/postgresql/data
ports:
- 5432:5432
adminer:
image: adminer
restart: always
ports:
- 8082:8080
volumes:
postgres-vol:
Later on you probably gonna need to prune your volume
1 Like
tekki
(Tekki)
August 14, 2020, 9:06am
4
This works because you create a named volume that is located ‘inside’ Docker and not in the Windows file system.
technomonk
(Technomonk)
October 25, 2020, 8:27pm
5
Hi tecvaldo
Thanks been battling all day , permissions …
Now it works , you a star
mwaaas
(Mwaaas)
December 1, 2020, 11:36am
6
running the container in windows terminal then stopping it and running it in WSL2 fixed the issue for me
1 Like
I’m a WSL and Docker noob. Can anyone hold my hand on getting this working? I see what looks like a docker compose file here, but I’m a little clueless.
Try not to create the container from WSL, use the power shell from windows instead
docker run -d --name postgres-12 -e POSTGRES_PASSWORD=docker -p 5432:5432 -v F:\MyVolume\postgres-12:/var/lib/postgresql/data:rw postgres:12
This is works for me.
zavodyanka
(Zavodyanka)
September 20, 2022, 4:26pm
11
My solution is to start build from Windows PowerShell, then there is no issue with permissions.