CAPABILITY GENERATOR

LambdaTestTesting Locally Hosted Pages ● Docker Tunnel

Docker Tunnel


With the help of the Docker Tunnel, i.e., Docker and Lambda Tunnel, you can perform live interactive and automated cross-browser testing of your locally hosted projects on the LambdaTest platform, with the help of 2000+ real browsers (desktop and mobile) and operating systems.

With Docker Tunnel, you will also be able to test your stage, development, and production environments securely. You can also create multiple instances of Lambda Tunnel using this.

Prerequisites To Get Started With LambdaTest Docker Tunnel


  1. Download and set up Docker Desktop from here.
  2. You also need your LambdaTest Username and Access Key. You can get these from your LambdaTest’s profile.

How To Use Docker With Lambda Tunnel


Initially, you need to pull the Docker hub image of Lambda Tunnel. You can use the below command to raise the pull request.

In order to pull the other docker images from the hub, use the below command:

  • Legacy Alpine:
  • Alpine:
  • Legacy:
  • Burrow:

This image supports all the tunnel modifier flags available in the tunnel command-line binary and passes them as the entry point. Let us see some of them:

  • Version Checking: You can check the installed version of the Lambda Tunnel using the below command.

  • Basic Authentication and Login: You can login into your Lambda Tunnel with Docker image, with the help of below command:

  • Capturing logs in mounted volume on host machine: You can capture these logs with the help of below command:

  • Getting Tunnel status: You can fetch the current tunnel status using the Info API on the tunnel.

    Suppose the InfoAPI is available on the host over port 13001, then you need to expose the docker container port to host in the form 13001:8000. Use the below command to infuse the InfoAPI in the current docker image:

    Now, in order to fetch the current tunnel status, just execute the below command:

  • You can also use Proxy running on host machine at port 8082 having foo and bar as username and key as per the example shown below:

  • You can also use Proxy running on another docker container within same default bridge network, assuming the container in which proxy is running has IP 172.17.0.2.

    Note: The IP can be found from inside of the container or by inspecting the network to which container is attached.

    Consider the below example:

  • You can also use Proxy running on another docker container within same custom bridge network, assuming the container in which proxy is running has IP 172.17.0.2.

    Note: When you create custom network, containers can reach each other using container names due to automatic service discovery. Assuming that custom-network already exists and container named proxy-service has a proxy server running.

    Consider the below example:

  • In order to stop the Docker tunnel, you can use the above mentioned InfoAPI, according to the command shown below:

How To Make Use Of Lambda Tunnel With Docker Image For Development


By default Lambda tunnel can no longer access web apps running on host machines or other docker containers using localhost or 127.0.0.1 when you run it using docker container. This means that the test scripts need to be modified in a way that they can access the target web app, according to the docker network topology and host operating system.

For Linux Machines:

On Linux, containers can run in a special network mode called host. This network mode makes the container use host’s network stack and doesn’t create an isolated one for the containers. Running the following command makes the tunnel containers run with host networking and can access the host’s network. The test scripts can access services running on the host machine using the localhost.

For Mac and Windows Machines:

Unfortunately, on both mac and windows, host networking mode is not available due to docker-machine implementation. The recommended approach to access services on the host machine is to use a special hostname host.docker.internal, which resolves to the host machine.

You can find more details on these, using this link for Mac, and this link for Windows respectively.

The test scripts need to use this special hostname to access the web services running on the host machine. The most idiomatic way of testing docker infra is creating a custom bridge network and access services using their container names. This method works on all operating systems

Conclusion


Test your locally hosted pages and privately hosted pages at LambdaTest Selenium Test Automation Platform using Docker Tunnel, via SSH based integration tunnel. If you still have any doubts or questions, please don’t hesitate to contact us. Our experts are available on 24×7 chat support. You can also drop us a mail at support@lambdatest.com.

Happy testing! 🙂