AccessDeniedException when taking a snapshot of ES index in local machine

Getting below error when taking snapshot of the index.

----------------------- Error -----------------------

java.lang.IllegalStateException: Unable to access 'path.repo' (/Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot)
es02    | Likely root cause: java.nio.file.AccessDeniedException: /Users
version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
    container_name: es01
    environment:
      - node.name=es01
      - node.roles=master,data
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - path.repo=/Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot
    ulimits:
      memlock:
        soft: -1
        hard: -1
    volumes:
      - ./volumes/elasticsearch/data:/usr/share/elasticsearch/data
    ports:
      - 9200:9200
    networks:
      - elastic
  es02:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
    container_name: es02
    environment:
      - node.name=es02
      - node.roles=master,data
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - path.repo=/Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9301:9200
    networks:
      - elastic
  es03:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
    container_name: es03
    environment:
      - node.name=es03
      - node.roles=master,data
      - cluster.name=es-docker-cluster
      - discovery.seed_hosts=es01,es02,es03
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
      - path.repo=/Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot
    ulimits:
      memlock:
        soft: -1
        hard: -1
    ports:
      - 9302:9200
    networks:
      - elastic

volumes:
  data01:
    driver: local

networks:
  elastic:
    driver: bridge

----------------docker-compose.yml-------------------
I have tried giving permission to the snapshot directory with this command for 'mlyedge', 'root', '1000' users but none of this seem to be resolving the issue.

sudo chown -R mlyedge:mlyedge /Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot
sudo chown -R root:root /Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot
sudo chown -R 1000:1000 /Users/mlyedge/gitrepos/search-query-service/compose/volumes/ESnapshot

I think that perhaps the issue is that you set the path.repo to a filesystem / path that is on your host not inside the docker container so docker knows nothing about it... I think you are going to need to mount or bind that for the docker container as well I believe.

I am not the docker expert on mounting storage but perhaps look here

Hi Thank you. This was helpful.