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

  • 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.
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.
bootstrap.memory_lock: true

Then kibana-node01.yml.

# copy the defaults to the custom file, refer to https://www.elastic.co/guide/en/kibana/8.1/docker.html#docker-defaults
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 .

  • Any help or reminders are appreciated.

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

thank you very much!

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

  • You don't need to set network.host: , 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.

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