Docker Community Forums

Share and learn in the Docker community.

Postgres in WSL 2 with Docker - Operation not permitted when I share volumes enter windows folder

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

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.

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

This works because you create a named volume that is located ‘inside’ Docker and not in the Windows file system.

Hi tecvaldo

Thanks been battling all day , permissions …

Now it works , you a star