JMeter - docker - java.net.connectexception

2019-06-10 06:49发布

I am trying to do a distributed load testing using JMeter in AWS EC2 instances.

I have 1 master and 2 slaves. All are ubuntu instances. They all have java and jmeter installed.

I am able to successfully execute the test in the slaves w/o issues. (When i do no use docker) (JMeter uses RMI to control slaves)

Now, I am thinking of using docker in the slaves as I might be adding more slaves. I do not want to set up the slave machines everytime. So docker seems to be a good choice.

In the docker container, everything seems to be correct, all the necessary ports are open.

Issue:

Whenever I use docker container to run the jmeter-server in the slave, if i try to connect to it from the master, It throws java.net.connectexception connection refused connect <ip address> error.

If I telnet from the master to slave, it is able to connect successfully.

My dockerfile:

FROM ubuntu
RUN apt-get update
RUN apt-get -y install wget
RUN apt-get -y install default-jre
RUN mkdir /jmeter
RUN cd /jmeter/ ; wget http://www.us.apache.org/dist//jmeter/binaries/apache-jmeter-2.13.tgz ; tar -xzf apache-jmeter-2.13.tgz ; rm apache-jmeter-2.13.tgz
ENV JMETER_HOME /jmeter/apache-jmeter-2.13/
ENV PATH $JMETER_HOME/bin:$PATH
EXPOSE 1099 7000 50000
ENTRYPOINT $JMETER_HOME/bin/jmeter-server -Djava.rmi.server.hostname=$LOCALIP 

This is how i create a container

sudo docker run -dit -e LOCALIP='10.11.12.13' -p 7000:7000 -p 1099:1099 -p 50000:50000 "mydockerimg" /bin/bash

I do not understand what is happening here!! How should i fix this?


UPDATE: Tried as per @arcticless suggestion

enter image description here

1条回答
三岁会撩人
2楼-- · 2019-06-10 07:03

Try running your container with the flag --net=host and without exposing any port. It should work. sudo docker run --net=host -dit -e LOCALIP='your_ip' "mydockerimg" /bin/bash

查看更多
登录 后发表回答