Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

is it feasible to run a dockerized locatunnel on Mac?

As an alternative to the very famous ngrok I used to use efrecon/localtunnel docker image to expose my http server on the internet for testing purposes.

With linux I used to:

  • start my local HTTP server (let’s say on port 8080)
  • start a container running the efrecon/localtunnel image with --network host:
    docker run -it -d --name localtunnel --network host efrecon/localtunnel --port 8080
    
  • fetch the provided URL:
    export LOCAL_TUNNEL_URL=$(docker logs localtunnel | cut -d ' ' -f 4)
    
  • et voilĂ :
    curl $LOCAL_TUNNEL_URL/hello
    

Of course, with MacOs it’s not possible to use the --network=host flag but I’m not finding the correct way to perform the same.
I tried multiple combinations like:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

docker run -it -d --name localtunnel -p 8443:8080 efrecon/localtunnel --port 8080
curl $LOCAL_TUNNEL_URL:8443/hello

docker run -it -d --name localtunnel -p 443:8080 efrecon/localtunnel --port 8080
curl $LOCAL_TUNNEL_URL/hello

docker run -it -d --name localtunnel -p 80:8080 efrecon/localtunnel --port 8080
curl $LOCAL_TUNNEL_URL/hello

docker run -it -d --name localtunnel -p 9090:8080 efrecon/localtunnel --port 8080
curl $LOCAL_TUNNEL_URL:9090/hello

but none of them gave me results, only a dangling request waiting indefinitely to be achieved.
Any direct experience on how is localtunnel remote port-forwarding configured?

>Solution :

Interesting question, I think is something not specified in the documentation that’s why you incurred in this.

I don’t think it’s feasible, because the dockerized version of Localtunnel, implementing the reverse port-forwarding, needs the process to which the call is redirected to be on the same host, so on localhost:8080. The problems are two: you cannot pass the -p 8080:8080 because port 8080 is already occupied on you local machine by your local server process and, besides that, even if it would have been possible, the remote host is forwarding the calls to the container on port 8080, your process should be reachable on the localhost:8080 of the container, but it’s not, because the server process is outside the container.
The advantage of Linux is that Docker can share the host network, which doesn’t only mean that every container is reachable via localhost, but also the opposite thing, which means that every container can reach any other container or local process on localhost too.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading