Docker rootless volumes mounting: difference between service and global option

Hello to everyone,

I want to use docker rootless for my opendistro (elasticsearch) project.

I ran in an issue where my container can’t write to a folder. The mounting point was specified in the service config like this :

services:
  es01
  [...]
    volumes :
      - /srv/docker/es01:/usr/share/elasticsearch/

I had the 755 rights on /srv/docker/es01

To debug the issue I run chmod 777 /srv/docker/es01

But after my docker-compose up my folder was back in 755.

I’m not sure to understand why. I have tried to google it, but I didn’t find anything. Does someone have explications or links to help me understand ?

And I work around my problem and I finally fix it using this configuration :


services:
  es01
  [...]
    volumes :
      - ofde-data1:/usr/share/elasticsearch/

volumes:
  odfe-data1:
    driver: local
    driver_opts:
      type: none
      o: bind
      device: /srv/docker/es01

I don’t understand the difference between this 2 configurations and why it solve my problems.

It’s one of my first post, I hope I didn’t forget anything.

Thanks