0

My AUT runs in a docker container and the URL for it is "http://localhost:8080/" . Now when I trigger the tests using Zalenium it launches the browser but when it tries to navigate to the AUT's URL it can't find it. Is it because my AUT runs in a docker container and Zalenium also runs in a separate docker container and they both can't communicate with each other?

Thanks in Advance.

Anoop
  • 51
  • 5

1 Answers1

0

I think that's how it supposed to work. You ideally want contains to have isolation until you say otherwise.

A quick solution, on your selenium scripts, instead of localhost specify your <machine name>. That way, your scripts in zalenium will look to resolve the address through the network (which is still you) instead of trying to internally resolve localhost on their own network ring.

While this will probably work for you machine, it's a little bit static. You'll probably want to script it as part of your solution so it connects to multiple.

In java you can use this to get the running machine name:

    InetAddress addr;
    addr = InetAddress.getLocalHost();
    hostname = addr.getHostName();

Alternatively, to make a more portable solution, you might want to review the docker networking pages.

I think this tutorial might help you. "Networking with standalone containers" sounds about right.

Long and short of it is when you run your docker containers you need to attach them to the same network. The default is:

--network bridge

Or create your own bridge:

docker network create --driver bridge MyBridgeName

and run both your containers on that bridge name:

docker run -dit --name MyImageName --network MyBridgeName ImageToRun
docker run -dit --name OtherName --network MyBridgeName OtherImageToRun
RichEdwards
  • 3,423
  • 2
  • 6
  • 22