I am trying to test my localhost service using Gatling inside Docker using MacOS.
I run Docker using:
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 using '--host' enables using host network from inside Docker.
My service runs o port 9000, so my base url in Gatling, so I define it like that:
private val baseUrl = "http://127.0.0.1:9000"
private val httpProtocol = http
.baseUrl(baseUrl)
Although I keep getting:
AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:9000
Is there an issue with my config, or Gatling limitation?
Change the host address from http://127.0.0.1
to host.docker.internal
and it should work.
In essence host.docker.internal
will returns the IP for our docker host. But this feature only exists in Docker for Mac OSX & Docker for Windows. You could read more about this feature here: