# How to set path.data set to multiple paths within docker

**URL:** <https://discuss.elastic.co/t/how-to-set-path-data-set-to-multiple-paths-within-docker/204162>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [October 18, 2019, 4:46am UTC](https://discuss.elastic.co/t/how-to-set-path-data-set-to-multiple-paths-within-docker/204162 "2019-10-18T04:46:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Petr.Simik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petr.simik/32/38082_2.png) [@Petr.Simik](https://discuss.elastic.co/u/Petr.Simik)\
**Post date:** [October 18, 2019, 4:46am UTC](https://discuss.elastic.co/t/how-to-set-path-data-set-to-multiple-paths-within-docker/204162/1 "2019-10-18T04:46:28Z")

</div>

I found it is possible to configure `path.data` to multiple paths  
[https://www.elastic.co/guide/en/elasticsearch/reference/master/path-settings.html](https://www.elastic.co/guide/en/elasticsearch/reference/master/path-settings.html)

I want to add ssd1+ssd2 as a disk to elastic-node1 and ssd3+4 to elastic-node2  
I also want to add directory from non-ssd /mnt/data for snapshots and warm tier indexes..

> user@host3:~$ df -h  
> Filesystem Type Size Used Avail Use% Mounted on  
> /dev/sdb xfs 26T 34M 26T 1% /mnt/data  
> /dev/mapper/ssd1-volume xfs 745G 33M 745G 1% /mnt/ssd1  
> /dev/mapper/ssd2-volume xfs 745G 33M 745G 1% /mnt/ssd2  
> /dev/mapper/ssd3-volume xfs 745G 33M 745G 1% /mnt/ssd3  
> /dev/mapper/ssd4-volume xfs 745G 33M 745G 1% /mnt/ssd4

how can I achieve this configuration in docker-compose ?  
How can I add more volumes to elastic node using docker config?

thank u

> user@host3:~/es-node31$ cat docker-compose.yml  
> version: '2.2'  
> services:  
> es-node31:  
> image: [docker.elastic.co/elasticsearch/elasticsearch:6.8.0](http://docker.elastic.co/elasticsearch/elasticsearch:6.8.0)  
> container\_name: es-node31  
> environment:  
> - node.name=es-node31  
> - "discovery.zen.ping.unicast.hosts=host2.domain.int,host3.domain.int"  
> - cluster.name=cem-docker-cluster  
> - bootstrap.memory\_lock=true  
> - "ES\_JAVA\_OPTS=-Xms24g -Xmx24g"  
> ulimits:  
> memlock:  
> soft: -1  
> hard: -1  
> ports:  
> - 9200:9200  
> - 9300:9300  
> cpuset: "0-11"  
> network\_mode: host  
> volumes:  
> - /mnt/ssd1/esdata1:/usr/share/elasticsearch/data  
> - /mnt/ssd2/esdata2:/usr/share/elasticsearch/data ??? how to set this ???

---

<div class="post-metadata">

**Author:** ![Petr.Simik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petr.simik/32/38082_2.png) [@Petr.Simik](https://discuss.elastic.co/u/Petr.Simik)\
**Post date:** [October 21, 2019, 6:57am UTC](https://discuss.elastic.co/t/how-to-set-path-data-set-to-multiple-paths-within-docker/204162/2 "2019-10-21T06:57:13Z")

</div>

I am thinking of the approach to define elasticsearch.yml outside docker and define it

> -v custom\_elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml  
> ...  
> path:  
> data:  
> - /usr/share/elasticsearch/data1  
> - /usr/share/elasticsearch/data1  
> ...

and in docker compose file link it this way

> volumes:
> 
> - /mnt/ssd1/esdata1:/usr/share/elasticsearch/data1
> - /mnt/ssd2/esdata2:/usr/share/elasticsearch/data2

or

create and build docker image with the same setup

> FROM [docker.elastic.co/elasticsearch/elasticsearch:7.4.0](http://docker.elastic.co/elasticsearch/elasticsearch:7.4.0)  
> COPY --chown=elasticsearch:elasticsearch elasticsearch.yml /usr/share/elasticsearch/config/

the first approach seems better/simplier  
any experiences appretiated?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [October 21, 2019, 7:20am UTC](https://discuss.elastic.co/t/how-to-set-path-data-set-to-multiple-paths-within-docker/204162/3 "2019-10-21T07:20:56Z")

</div>

Both sound fine. Another option (that I prefer) is to combine your pairs of disks together (using e.g. RAID0 or LVM) and offer a single filesystem to each node, which fits more nicely with the default `docker-compose` setup that expects a single data path.

---

<div class="post-metadata">

**Author:** ![Petr.Simik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/petr.simik/32/38082_2.png) [@Petr.Simik](https://discuss.elastic.co/u/Petr.Simik)\
**Post date:** [November 5, 2019, 6:44am UTC](https://discuss.elastic.co/t/how-to-set-path-data-set-to-multiple-paths-within-docker/204162/4 "2019-11-05T06:44:51Z")

</div>

Finally my docker file looks like:  
docker-compose v2 has cpuset parameter to limit specific CPU, but docker-compose v3 support this only in as part of resource,deploy available only in swarm or docker stack.  
The workaround is to use docker-compose --compatibility up -d

the storage i realised to use lvm to create single volume group rather than attaching 2 disk volumes.

the previous option wouldn't work because there are no 2 data directories inside default docker image so we would have to created them before build. Using 1 disk via LVM was easier.

I am not 100% sure if this is good config for production. I do not like --compatibility options and I concern if this would cause some problems in future.

docker-compose.yml

> version: '3.3'  
> services:  
> es-oscar21:  
> image: [docker.elastic.co/elasticsearch/elasticsearch:6.8.0](http://docker.elastic.co/elasticsearch/elasticsearch:6.8.0)  
> container\_name: es-oscar21  
> restart: always  
> environment:  
> - node.name=es-oscar21  
> - "discovery.zen.ping.unicast.hosts=oscar3.corp,oscar2.corp"  
> - http.cors.enabled=true  
> - http.cors.allow-origin=\*  
> - cluster.name=corp-docker-cluster  
> - bootstrap.memory\_lock=true  
> - "ES\_JAVA\_OPTS=-Xms24g -Xmx24g"  
> ulimits:  
> memlock:  
> soft: -1  
> hard: -1  
> volumes:  
> - /mnt/ssd1/esdata1:/usr/share/elasticsearch/data  
> - /mnt/ssd1/eslog1:/var/log/elasticsearch  
> ports:  
> - 9200:9200  
> - 9300:9300  
> deploy:  
> resources:  
> limits:  
> cpus: '12'  
> network\_mode: host  
> es-oscar22:  
> image: [docker.elastic.co/elasticsearch/elasticsearch:6.8.0](http://docker.elastic.co/elasticsearch/elasticsearch:6.8.0)  
> restart: always  
> container\_name: es-oscar22  
> environment:  
> - node.name=es-oscar22  
> - "discovery.zen.ping.unicast.hosts=oscar3.corp,oscar2.corp"  
> - http.cors.enabled=true  
> - http.cors.allow-origin=\*  
> - cluster.name=corp-docker-cluster  
> - bootstrap.memory\_lock=true  
> - "ES\_JAVA\_OPTS=-Xms24g -Xmx24g"  
> ulimits:  
> memlock:  
> soft: -1  
> hard: -1  
> volumes:  
> - /mnt/ssd2/esdata2:/usr/share/elasticsearch/data  
> - /mnt/ssd2/eslog2:/var/log/elasticsearch  
> ports:  
> - 9201:9200  
> - 9301:9300  
> deploy:  
> resources:  
> limits:  
> cpus: '12'  
> network\_mode: host

---

<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:** [December 3, 2019, 6:44am UTC](https://discuss.elastic.co/t/how-to-set-path-data-set-to-multiple-paths-within-docker/204162/5 "2019-12-03T06:44:52Z")

</div>

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