An error occurred curl: (52) Empty reply from server

Good day, a problem arose when requesting the following address: curl -X GET "http://localhost:9200" an error occurs curl: (52) Empty reply from server. The code for connecting to the elasticsearch service is launched from the Docker container:

elasticsearch:
 container_name: elasticsearch_container
 image: docker.elastic.co/elasticsearch/elasticsearch:8.15.3
 restart: always
 environment:
 ES_JAVA_OPTS: -Xmx2g -Xms2g
 bootstrap.memory_lock: "true"
 discovery.type: single-node
 xpack.security.enabled: "false"
 xpack.security.authc.api_key.enabled: "true"
 xpack.monitoring.collection.enabled: "true"
 xpack.security.enrollment.enabled: "true"
 xpack.security.authc.token.enabled: "true"
 ports:
 - 9300:9300
 - 9200:9200
 volumes:
 - ./docker-volumes/elasticsearch-data:/usr/share/elasticsearch/data
 networks:
 - elastic
 kibana:
 container_name: kibana_container
 image: docker.elastic.co/kibana/kibana:8.15.3
 restart: always
 environment:
 - ELASTICSEARCH_HOSTS=["http://elasticsearch_container:9200"]
 ports:
 - 5601:5601
 networks:
 - elastic
 volumes:
 - ./kibana.yml/:/usr/share/kibana/config/kibana.yml:ro
 depends_on:
 - elasticsearch

For some reason, the elasticsearch-data directory is empty and the console displays errors:

failed to obtain node locks, tried [/usr/share/elasticsearch/data]; maybe these locations are not writable or multiple nodes were started on the same data path?
...
Caused by: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/data/node.lock
...
Caused by: java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/node.lock

You have a volume / permissions / paths error etc...

Try absolute paths, make sure docker user has permissions to ready write... that is what the error is telling you...

Also when you mess up a volume it can create a bad file or directory that needs to be cleaned up...

BTW this is my single node node security

TAG=8.17.0 docker compose

# version: '2.26.0'
services:
  elasticsearch:
    container_name: es01
    image: docker.elastic.co/elasticsearch/elasticsearch:${TAG}
    # 8.x
    environment: ['ES_JAVA_OPTS=-Xms8g -Xmx8g','bootstrap.memory_lock=true','discovery.type=single-node','xpack.security.enabled=false', 'xpack.security.enrollment.enabled=false']
    ports:
      - 9200:9200
    networks:
      - elastic
    ulimits:
      memlock:
        soft: -1
        hard: -1
      nofile:
        soft: 65536
        hard: 65536
    deploy:    
      resources:
          limits:
            cpus: '2.0'
          reservations:
            cpus: '1.0'

  kibana:
    image: docker.elastic.co/kibana/kibana:${TAG}
    container_name: kib01
    environment:
      XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: d1a66dfd-c4d3-4a0a-8290-2abcb83ab3aa
      # LOGGING_ROOT_LEVEL: debug
    ports:
      - 5601:5601
    networks:
      - elastic
    deploy:    
      resources:
          limits:
            cpus: '2.0'
          reservations:
            cpus: '1.0'

networks:
  elastic:

In other compose were I want to maintain the volume

    volumes:
      - certs:/usr/share/elasticsearch/config/certs
      - esdata01:/usr/share/elasticsearch/data
....
volumes:
  certs:
    driver: local
  esdata01:
    driver: local
  kibanadata:
    driver: local