elasticsearch error: /usr/local/bin/docker-entrypoint.sh: cannot create temp file for here-document: Permission denied

I am new to elasticsearch and i want to install ELK on my linux local server using docker compose method. I took the .env and docker-compose files from the following url:

[elasticsearch/docs/reference/setup/install/docker at 8.15 · elastic/elasticsearch · GitHub](https://stackoverflow.com/](https://)

but when I want to up the container I get the following error:

WARN[0000] /workdir/app/elasticsearch/docker-compose.yaml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
es01-1  | Created elasticsearch keystore in /usr/share/elasticsearch/config/elasticsearch.keystore
es03-1   | /usr/local/bin/docker-entrypoint.sh: line 84: cannot create temp file for here-document: Permission denied
setup-1  | Setting file permissions
setup-1  | Waiting for Elasticsearch availability
es01-1   | /usr/local/bin/docker-entrypoint.sh: line 73: cannot create temp file for here-document: Permission denied
es02-1   | /usr/local/bin/docker-entrypoint.sh: line 84: cannot create temp file for here-document: Permission denied

does anyone know why this is?

Thankyou

I encountered a similar issue with the error message:

elasticsearch error: /usr/local/bin/docker-entrypoint.sh: cannot create temp file for here-document: Permission denied

After some troubleshooting, I found a workaround that worked for me. The solution involves rewriting the Dockerfile to change the permissions of the /tmp folder to 777. Here's a basic example of how to modify the Dockerfile:

FROM docker.elastic.co/elasticsearch/elasticsearch:8.15.2

USER root
# Change permissions for /tmp
RUN chmod 777 /tmp

USER elasticsearch

After building the new image with these changes, I was able to start the container without encountering the permission error.

This issue seems to stem from some underlying environmental problems, and while this workaround is effective, I can't pinpoint the exact root cause. For more details on this issue, you can refer to the discussion here: Debuerreotype GitHub Issue #83.

I hope this helps