Docker + postgres = initdb: error: could not change permissions of directory "/data/postgres": Operation not permitted

325 Views Asked by At

I am using M2 chip. I am using colima. Docker version 24.0.5

version: "3.5"
volumes:
  postgres:

services:

  pgsql2:
    ports:
      - "5432:5432"
    container_name: "${LOCALSTACK_DOCKER_NAME-pgsql2}"
    image: postgres:15.3
    restart: always
    environment:
      POSTGRES_PASSWORD: password
      POSTGRES_HOST_AUTH_METHOD: trust
      PGDATA: "/data/postgres"
    volumes:
      - "./postgres:/data/postgres"
      - "./dump.sql:/docker-entrypoint-initdb.d/dump.sql"
    user: ${UID}:${GID}

This is my docker compose file. I want to initialize database while running the container. I am getting this error while doing docker-compose up pgsql2

initdb: error: could not change permissions of directory “/data/postgres”: Operation not permitted
pgsql2 | fixing permissions on existing directory /data/postgres …

Tried most of solution like changing image or using named volumes. Any help is appreciated!

Tried most of solution like changing image or using named volumes initdb: could not change permissions of directory on Postgresql container

0

There are 0 best solutions below