# When mounting \`elasticsearch.yml\`, docker displays \`Device or resource busy\`

**URL:** <https://discuss.elastic.co/t/when-mounting-elasticsearch-yml-docker-displays-device-or-resource-busy/300981>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [March 29, 2022, 2:23pm UTC](https://discuss.elastic.co/t/when-mounting-elasticsearch-yml-docker-displays-device-or-resource-busy/300981 "2022-03-29T14:23:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![linghengqian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/linghengqian/32/103651_2.png) [@linghengqian](https://discuss.elastic.co/u/linghengqian)\
**Post date:** [March 29, 2022, 2:23pm UTC](https://discuss.elastic.co/t/when-mounting-elasticsearch-yml-docker-displays-device-or-resource-busy/300981/1 "2022-03-29T14:23:47Z")

</div>

- I tried to mount `elasticsearch.yml` and `kibana.yml` inside docker-compose.yml.
- For kibana, it is very smooth, but for Elasticsearch, an exception is thrown and the corresponding service is aborted, which confuses me. The following is the log output by Elasticsearch on the docker daemon.
- ![img](https://us1.discourse-cdn.com/elastic/original/3X/8/9/89cb9b065176479273d0c3779dbd4a20b9fc34c6.png)

```auto
Exception in thread "main" java.nio.file.FileSystemException: /usr/share/elasticsearch/config/elasticsearch.yml.cvrM1wfsRz-M7StPG7vFHw.tmp -> /usr/share/elasticsearch/config/elasticsearch.yml: Device or resource busy

at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)

at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)

at java.base/sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:416)

at java.base/sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:266)

at java.base/java.nio.file.Files.move(Files.java:1432)

at org.elasticsearch.xpack.security.cli.AutoConfigureNode.fullyWriteFile(AutoConfigureNode.java:1136)

at org.elasticsearch.xpack.security.cli.AutoConfigureNode.fullyWriteFile(AutoConfigureNode.java:1148)

at org.elasticsearch.xpack.security.cli.AutoConfigureNode.execute(AutoConfigureNode.java:687)

at org.elasticsearch.common.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:81)

at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)

at org.elasticsearch.cli.Command.main(Command.java:77)

at org.elasticsearch.xpack.security.cli.AutoConfigureNode.main(AutoConfigureNode.java:157)

```

- I give below two files `elasticsearch-node01.yml` and `kibana-node01.yml` in the same directory. The first is `elasticsearch-node01.yml`.

```nohighlight
bootstrap.memory_lock: true
network.host: 0.0.0.0

```

Then `kibana-node01.yml`.

```nohighlight
# copy the defaults to the custom file, refer to https://www.elastic.co/guide/en/kibana/8.1/docker.html#docker-defaults
server.host: 0.0.0.0
server.shutdownTimeout: 5s
elasticsearch.hosts: ['http://elasticsearch:9200']
monitoring.ui.container.elasticsearch.enabled: true

```

- I can be sure that I have executed `wsl -d docker-desktop` and `sysctl -w vm.max_map_count=262144` to get rid of the limit, but I am completely unable to understand why `elasticsearch-node01.yml` after creating the file multiple times mount fails, while the `kibana.yml` mounts fine. In addition, I need to clarify that if the `elasticsearch-node01.yml` is deleted and the configuration is placed in the environment variables of the `docker-compose.yml`, everything works fine.

- 

- A reproduced repository is at [GitHub - linghengqian/elasticsearch-docker-compose-test: elasticsearch-docker-compose-test](https://github.com/linghengqian/elasticsearch-docker-compose-test) .

- Any help or reminders are appreciated.

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [March 30, 2022, 3:22am UTC](https://discuss.elastic.co/t/when-mounting-elasticsearch-yml-docker-displays-device-or-resource-busy/300981/2 "2022-03-30T03:22:21Z")

</div>

Thanks for bringing this up. We were able to reproduce this and looking into it. You can track progress in [Elasticsearch fails to start in Docker, when `elasticsearch.yml` is bind mount · Issue #85463 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/85463)

---

<div class="post-metadata">

**Author:** ![linghengqian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/linghengqian/32/103651_2.png) [@linghengqian](https://discuss.elastic.co/u/linghengqian)\
**Post date:** [March 30, 2022, 5:35am UTC](https://discuss.elastic.co/t/when-mounting-elasticsearch-yml-docker-displays-device-or-resource-busy/300981/3 "2022-03-30T05:35:40Z")

</div>

thank you very much!

---

<div class="post-metadata">

**Author:** ![ikakavas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ikakavas/32/34430_2.png) [@ikakavas](https://discuss.elastic.co/u/ikakavas)\
**Post date:** [March 31, 2022, 2:49am UTC](https://discuss.elastic.co/t/when-mounting-elasticsearch-yml-docker-displays-device-or-resource-busy/300981/4 "2022-03-31T02:49:12Z")

</div>

Until this is investigated and resolved, I'd suggest as a workaround :

- You don't need to set `network.host: 0.0.0.0` , we add this by default to the Elasticsearch.yml in Docker.
- For `bootstrap.memory_lock`, you can pass it as a parameter in docker run, such as `-e "bootstrap.memory_lock=true"`

This way, you don't need to bind mount the Elasticsearch.yml file.

---

<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:** [April 28, 2022, 2:50am UTC](https://discuss.elastic.co/t/when-mounting-elasticsearch-yml-docker-displays-device-or-resource-busy/300981/5 "2022-04-28T02:50:11Z")

</div>

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