influxdb - 在 docker 中运行 K6 脚本时出现 ModuleSpecifier 错误
问题描述
我对docker的了解有限。但这就是我所做的。我安装了docker桌面。为 influxdb 1.8 和 grafana 和 loadimpact/k6 提取图像。为运行良好的 influxdb 和 grafana 创建了容器。
http://localhost:3000/ -> 工作 http://localhost:8086/ -> 找不到 404 页面
我想在 docker 中运行我的 k6 脚本,将结果保存在 influxdb 中,然后使用 grafana 根据 influxdb 中的数据创建自定义仪表板。
当我从 K6 脚本所在文件夹的命令提示符下发出以下命令时:
docker run -v /k6 -i loadimpact/k6 run --out influxdb=http://localhost:8086/myk6db - <K6-script.js
我收到以下错误。
time="2021-10-16T10:09:58Z" level=error msg="The moduleSpecifier \"./libs/shim/core.js\" couldn't be found on local disk. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container, see https://k6.io/docs/using-k6/modules#using-local-modules-with-docker.\n\tat reflect.methodValueCall (native)\n\tat file:///-:205:34(24)\n" hint="script exception"
该文件夹是 K6-script.js 所在的文件夹,另外两个文件夹是 K6 和库,它们是在 K6-script.js 中导入的。
然后我参考了 [https://k6.io/docs/using-k6/modules/#local-filesystem-modules][1] 并给出了以下命令
docker run -v //c/loadtesting:/src -i loadimpact/k6 run --out influxdb=http://localhost:8086/myk6db K6-script.js
这给了我以下错误。
level=error msg="The moduleSpecifier \"K6-script.js\" couldn't be found on local disk. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container, see https://k6.io/docs/using-k6/modules#using-local-modules-with-docker. Additionally it was tried to be loaded as remote module by prepending \"https://\" to it, which also didn't work. Remote resolution error: \"Get \"https://K6-script.js\": dial tcp: lookup K6-script.js on 192.168.65.5:53: no such host\""
如何解决此错误并使用 influxdb 在 docker 中运行 K6 脚本?
解决方案
当我给出以下命令时,经过多次试验和错误,测试运行了。它无法连接到 InfluxDB 数据库,但这是我需要解决的另一个问题。但除此之外,测试运行。
docker run -v //c/loadtesting:/src -i loadimpact/k6 run --out influxdb=http://localhost:8086/myk6db /src/K6-script.js
我认为它需要容器内的脚本路径来运行脚本。
推荐阅读
- php - LARAVEL 参数 1 传递给 ... 必须是数组类型,给定 int
- mysql - Woocommerce:获取每次使用优惠券的总订单价值(SQL 查询)
- php - PHP - 关联表的爆炸结果查询
- java - Android minifyEnabled = true shrinkResources = true 保持应用崩溃
- java - Facebook Graph API 的内部服务器错误异常
- c# - 即使 DataRow 的属性值未修改,DataView.ListChanged 事件也未正确触发
- cognos - COGNOS 11.1.3 - 下拉提示禁用参数名称和虚线
- ruby-on-rails - 调试导致事务回滚的 RailsAdmin 错误
- wpf - 每次鼠标悬停在 WPF 上时调用转换器的 Convert() 方法
- google-api - Youtube (Google) 批准的范围/权限列表