Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从Docker内部的gatling仿真连接到localhost_Docker_Localhost_Gatling_Connection Refused - Fatal编程技术网

从Docker内部的gatling仿真连接到localhost

从Docker内部的gatling仿真连接到localhost,docker,localhost,gatling,connection-refused,Docker,Localhost,Gatling,Connection Refused,我正在尝试使用MacOS在Docker内部使用Gatling测试本地主机服务 我运行Docker时使用: docker run -it -d --rm \ --network="host" \ -v $(PWD)/conf:/opt/gatling/conf \ -v $(PWD)/user-files:/opt/gatling/user-files \ -v $(PWD)/results:/opt/gatling/results \ --name $

我正在尝试使用MacOS在Docker内部使用Gatling测试本地主机服务

我运行Docker时使用:

  docker run -it -d --rm \
    --network="host" \
    -v $(PWD)/conf:/opt/gatling/conf \
    -v $(PWD)/user-files:/opt/gatling/user-files \
    -v $(PWD)/results:/opt/gatling/results \
    --name $CONTAINER_NAME $IMAGE_NAME
Afaik使用“--host”可以从Docker内部使用主机网络

我的服务运行o port 9000,因此我的基本url为Gatling,因此我将其定义为:

  private val baseUrl = "http://127.0.0.1:9000"
  private val httpProtocol = http
    .baseUrl(baseUrl)
尽管我不断地得到:

AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:9000

我的配置或Gatling限制有问题吗?

将主机地址从
http://127.0.0.1
主机.docker.internal
,它应该可以工作

本质上,
host.docker.internal
将返回我们的docker主机的IP。但此功能仅存在于Docker for Mac OSX和Docker for Windows中。您可以在此处阅读有关此功能的更多信息:


将主机地址从
http://127.0.0.1
主机.docker.internal
,它应该可以工作

本质上,
host.docker.internal
将返回我们的docker主机的IP。但此功能仅存在于Docker for Mac OSX和Docker for Windows中。您可以在此处阅读有关此功能的更多信息:


您正在使用哪个操作系统?Mac还是Windows?我使用macOS,我会将其添加到您使用的操作系统的问题中?Mac还是Windows?我使用macOS,我会将其添加到问题中。谢谢,我能够连接到该服务。我想使用linux我必须明确地通过本地IP才能获得相同的结果?你能接受答案并关闭问题吗?谢谢,我能够连接到该服务。我想使用linux我必须显式地通过本地IP才能获得相同的结果?你能接受答案并结束这个问题吗?