Skip to content

Wrong ownership on bind mount #1010

@BigBoulard

Description

@BigBoulard

Hi guys,

Just trying to run a postgres 14.5 container using compose on docker-desktop (Engine 20.10.20 and Compose: v2.12.1) on macOS Monterey.

Everything works well using a volume, but here I need to use a bind mount for some reason and I get a wrong ownership error on startup.

** postgres container logs**

docker-postgres-bug-postgres-1 | PostgreSQL Database directory appears to contain a database; Skipping initialization
docker-postgres-bug-postgres-1 | 
docker-postgres-bug-postgres-1 | 2022-11-08 09:14:32.867 UTC [1] FATAL:  data directory "/var/lib/postgresql/data" has wrong ownership
docker-postgres-bug-postgres-1 | 2022-11-08 09:14:32.867 UTC [1] HINT:  The server must be started by the user that owns the data directory.

docker-compose.yml

version: '3'

services:

  postgres:
    image: 'postgres:15.0'
    ports:
      - "5432:5432"
    restart: always
    deploy:
      mode: replicated
      replicas: 1
    environment:
      POSTGRES_USER: postgres
      POSTGRES_PASSWORD: password
      POSTGRES_DB: users
    volumes:
      - ./db-data/postgres/:/var/lib/postgresql/data/
❯ ll
Permissions Size User          Date Modified Name
drwxr-xr-x     - bigboulard  8 Nov 10:08   db-data/

❯ ll db-data
Permissions Size User          Date Modified Name
drwx------     - bigboulard  8 Nov 10:09   postgres/

Thank you for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions