Running Ngrok in a container using docker

Adwaith R Krishna picture Adwaith R Krishna · Dec 4, 2018 · Viewed 7.5k times · Source

[https://github.com/gtriggiano/ngrok-tunnel ] runs ngrok inside a container. Ngrok is required to run in the container to avert security risks. But am facing problems after running the scripts, which generates the url

$ docker pull gtriggiano/ngrok-tunnel


$ docker run -it  -e "TARGET_HOST=localhost" -e "TARGET_PORT=3000" -p 4040 gtriggiano/ngrok-tunnel

enter image description here am running my rails app on localhost:3000

is it my problem or can it be fixed by altering the scripts(inside the repo)?

Answer

v_sukt picture v_sukt · Dec 4, 2018

No. if you execute -p with single number it's container port - host port is randomly assigned. Using -p, --publish ip:[hostPort]:containerPort at docker run can specify the the host port with the container port.

as of now the 4040 of container is exposed. Not sure if your service listens by default on it.

To get localhost port execute

docker ps

you'll see the actual port it's not listening on.

CONTAINER ID        IMAGE                     COMMAND             CREATED              STATUS              PORTS                     NAMES
1aaaeffe789d        gtriggiano/ngrok-tunnel   "npm start"         About a minute ago   Up About a minute   0.0.0.0:32768->4040/tcp   wizardly_poincare

here it's listening on localhost:32768