docker-compose up postgresql error, chown: changing ownership of ‘/var/lib/postgresql/data’: Operation not permitted

12,261

I entered at / and stay analyzing the folders. Than I set the command ls -la there and I saw that the folder was with root user. First I deleted the folder sudo rm -rf psqldata and after I setted permission sudo chmod 777 / to create the folder with my user mkdir psqldata and now it is working. I don't know why before it was working and suddenly it stoped. I hope this answer can help you too.

old folder ls -la drwxr-xr-x 2 root wheel 68 Jun 19 14:58 psqldata

new folder ls -la drwxr-xr-x 2 gtmiyabe wheel 68 Jun 20 10:07 psqldata

Share:
12,261
Takashi Miyabe
Author by

Takashi Miyabe

Updated on June 04, 2022

Comments

  • Takashi Miyabe
    Takashi Miyabe almost 2 years

    I'm working in a project and we use docker. The project was fine until last friday and today I started my computer (mac mini - macOS Sierra version 10.12.5 (16F73)) with an error. I'm trying to run docker-compose -f dev.yml -f docker-compose.yml up, but when I execute this it returns the following message :

    db_1 | chmod: changing permissions of ‘/var/lib/postgresql/data’: Operation not permitted.

    I had deleted all the docker containers and images docker rm $(docker ps -a -q) docker rmi $(docker images -q)but the error persists.

    My docker-compose.yml is this:

     version: '2'
    
     services:
    
     rabbitmq:
         restart: always
         image: rabbitmq:3.6
         environment:
           RABBITMQ_DEFAULT_USER: my_user
           RABBITMQ_DEFAULT_PASS: my_password
         ports:
           - "5672:5672"
           - "15672:15672"
       django:
         build: ./django
         command: gunicorn contactto.wsgi:application -b 0.0.0.0:8000
         environment: 
           - "TZ=Brazil/East"
         restart: always
         volumes: 
           - ./django:/usr/src/app
           - ./django/static:/usr/src/app/contactto/static
           - ./logs:/logs/
           - /asterisk/:/etc/asterisk/
         ports:
           - "8000:8000"
         links:
           - rabbitmq:rabbitmq
       node:
         build: ./node_6_8
         environment:
           - "TZ=Brazil/East"
         volumes_from:
           - django
       nginx:
         build: ./nginx
         restart: always
         environment: 
           - "TZ=Brazil/East"
         ports:
           - "80:80"
           - "443:443"
         volumes: 
           - /www/static
         volumes_from:
           - django
         links:
           - django:django
       worker:
         build: ./django
         command: su -m worker -c "celery worker -A contactto.celeryconf -Q default -n default@%h"
         environment: 
           - "TZ=Brazil/East"
         restart: always
         volumes:
           - ./django:/usr/src/app
           - ./django/static:/usr/src/app/contactto/static
           - ./logs:/logs/
           - /asterisk/:/etc/asterisk/
         links:
           - rabbitmq:rabbitmq
    
     volumes: 
       dbdata:
    

    My dev.yml is this:

    version: '2'
    
    services:
      db:
        image: postgres:9.5
        restart: always
        environment:
          POSTGRES_USER: my_user
          POSTGRES_PASSWORD: my_password
          POSTGRES_DB: my_db
        volumes:
          - /psqldata:/var/lib/postgresql/data
      django:
        environment:
          - "DJANGO_CONFIG_MODE=Development"
        depends_on:
          - db
      worker:
        environment:
          - "DJANGO_CONFIG_MODE=Development"
        links:
          - db:db
    

    Any help would be really appreciated.