# Elasticsearch docker image

**URL:** <https://discuss.elastic.co/t/elasticsearch-docker-image/212108>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [December 17, 2019, 7:47am UTC](https://discuss.elastic.co/t/elasticsearch-docker-image/212108 "2019-12-17T07:47:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![soniadailyview](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@soniadailyview](https://discuss.elastic.co/u/soniadailyview)\
**Post date:** [December 17, 2019, 7:47am UTC](https://discuss.elastic.co/t/elasticsearch-docker-image/212108/1 "2019-12-17T07:47:25Z")

</div>

Hi,

I'm using docker image of elasticsearch:6.4.0 and trying to add a repo path for backup.

But after I add mounted a named volume, the permission in the cluster containers is not owned by elasticsearch but root.

Here is the code snippet of my yaml file:

```
  data:
    image: elasticsearch:6.4.0
    configs:
      - source: es-data
        target: /usr/share/elasticsearch/config/elasticsearch.yml
      - source: jvm-options-data
        target: /usr/share/elasticsearch/config/jvm.options
    networks:
      - esnet
    volumes:
      - esdata:/usr/share/elasticsearch/data
      - backup:/usr/share/elasticsearch/backup
volumes:
  esdata:
  backup:

```

If I check the container, data folder is owned by elasticsearch but not backup folder.

```
drwxr-xr-x 2 root root 4096 Dec 16 09:24 backup
drwxrwxr-x 3 elasticsearch root 4096 Mar 12 2019 data

```

Is there any step I missed?

---

<div class="post-metadata">

**Author:** ![Magnus\_Kessler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnus_kessler/32/42001_2.png) [@Magnus\_Kessler](https://discuss.elastic.co/u/Magnus_Kessler)\
**Post date:** [December 17, 2019, 8:23am UTC](https://discuss.elastic.co/t/elasticsearch-docker-image/212108/2 "2019-12-17T08:23:54Z")

</div>

Try setting the `gid` and `uid` for the repository in your docker compose file as per the [docker compose file documentation](https://docs.docker.com/v17.09/compose/compose-file/#command).

Elasticsearch runs as `uid 1000` and `gid 1000` in the docker container, IIRC.

---

<div class="post-metadata">

**Author:** ![soniadailyview](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@soniadailyview](https://discuss.elastic.co/u/soniadailyview)\
**Post date:** [December 17, 2019, 9:18am UTC](https://discuss.elastic.co/t/elasticsearch-docker-image/212108/3 "2019-12-17T09:18:23Z")

</div>

Hi Magnus,

Thanks for the reply. But I'm wondering why data folder doesn't need to set gid/uid.

---

<div class="post-metadata">

**Author:** ![Magnus\_Kessler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnus_kessler/32/42001_2.png) [@Magnus\_Kessler](https://discuss.elastic.co/u/Magnus_Kessler)\
**Post date:** [December 18, 2019, 8:39am UTC](https://discuss.elastic.co/t/elasticsearch-docker-image/212108/4 "2019-12-18T08:39:25Z")

</div>

Have a look at the analysis in this [blog post](https://blog.leandot.com/2017/03/04/create-elastic-search-snapshot-docker.html). Essentially, the startup script inside the docker container ensures that the `data` directory is owned by `elasticsearch`. In `/usr/local/bin/docker-entrypoint.sh` you'll find:

```auto
if [["$(id -u)" == "0"]]; then
  # If requested and running as root, mutate the ownership of bind-mounts
  if [[-n "$TAKE_FILE_OWNERSHIP"]]; then
    chown -R 1000:0 /usr/share/elasticsearch/{data,logs}
  fi
fi

```

For your own mounted volumes, I'd use the `uid` and `gid` settings in the docker compose file rather than changing this script.

---

<div class="post-metadata">

**Author:** ![soniadailyview](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@soniadailyview](https://discuss.elastic.co/u/soniadailyview)\
**Post date:** [December 23, 2019, 3:35am UTC](https://discuss.elastic.co/t/elasticsearch-docker-image/212108/5 "2019-12-23T03:35:06Z")

</div>

Hi Magnus,

Thanks for your information! I did see that in the script. And actually, I know the reason what the default setting didn't include backup repo because usually you wouldn't put the backup files together with the data. Anyways, thanks a lot!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 20, 2020, 3:35am UTC](https://discuss.elastic.co/t/elasticsearch-docker-image/212108/6 "2020-01-20T03:35:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
