【发布时间】:2025-11-23 00:45:02
【问题描述】:
我正在使用 docker.elastic.co/elasticsearch/elasticsearch-oss:7.3.2 的 testcontainers.org,我想用它来测试我正在更新的插件,但我找不到在测试环境中安装它的方法。
我可以尝试将文件复制到里面并安装它
ElasticsearchContainer container = new ElasticsearchContainer("docker.elastic.co/elasticsearch/elasticsearch-oss:$ELASTIC_VERSION")
String pluginPath = "/usr/share/elasticsearch/$PLUGIN_FILE_NAME"
container.start()
container.copyFileToContainer(MountableFile.forHostPath(new File(PLUGIN_PLUGIN_PATH).toPath()), pluginPath)
ExecResult result = container.execInContainer("bin/elasticsearch-plugin", "install", "file://$pluginPath")
但是容器已经启动并且弹性搜索已经在运行,所以插件不会被加载,所以我需要杀死它并复制它的创建方式,听起来像是很多黑客攻击。有没有更好的方法来做到这一点?
【问题讨论】:
标签: java elasticsearch testcontainers