问题
Exception in thread "main" java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config/jvm.options
elasticsearch:7.6.0
docker elasticsearch run遇到两个问题
宿主机映射路径自定义 /web/es/config/ 和/web/es/data/
1)宿主机映射config文件夹权限问题 /usr/share/elasticsearch/config
2)宿主机映射data文件夹权限问题 /usr/share/elasticsearch/data
Exception in thread "main" java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config/jvm.options
at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:116)
at java.base/sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:219)
at java.base/java.nio.file.Files.newByteChannel(Files.java:374)
at java.base/java.nio.file.Files.newByteChannel(Files.java:425)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
at java.base/java.nio.file.Files.newInputStream(Files.java:159)
at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:64)
尝试1 失败 与privileged无关 --user="elasticsearch"无效
docker run --name es --user="elasticsearch" -v /web/es1/config/:/usr/share/elasticsearch/config -v /web/es1/data/:/usr/share/elasticsearch/data -p 9201:9200 -p 9301:9300 -e "discovery.type=single-node" --privileged=true -d elasticsearch:7.6.0
尝试2 查看宿主机映射目录权限及测试运行docker elasticsearch权限【命令 ll -a】
发现外部的权限root:root
容器内
解决
经过百般尝试,最终通过容器内部文件拷贝解决
1、测试单节点es运行
docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.6.0
2、拷贝es容器文件夹config到宿主机目录
docker cp elasticsearch:/usr/share/elasticsearch/config /web/es/
3、再运行完整es命令
docker run --name elasticsearch -v /web/es/config/:/usr/share/elasticsearch/config -v /web/es/data/:/usr/share/elasticsearch/data -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" --privileged=true -d elasticsearch:7.6.0