wernight / docker-ngrok

An Ngrok v2 container based on wizardapps/ngrok and fnichol/ngrok
https://hub.docker.com/r/wernight/ngrok/
MIT License
456 stars 143 forks source link

NGROK_AUTH not working #65

Open pak1989 opened 3 years ago

pak1989 commented 3 years ago

I am trying to run a ngrok container using tcp protocol to connet to a docker db running in another container. I noticed that after running the container the status was exited and running "docker logs containerId" gave me the alert that I needed the auth key. So I run again with NGROK_AUTH env var but the result is the same, looks like he is not using the variable.

$ docker ps
CONTAINER ID   IMAGE                                       COMMAND                  CREATED      STATUS                       PORTS                                                 NAMES
66380598a02f   nginx                                       "/docker-entrypoint.…"   2 days ago   Up About an hour             0.0.0.0:49153->80/tcp, :::49153->80/tcp               www
89307e3e25e9   store/oracle/database-enterprise:12.2.0.1   "/bin/sh -c '/bin/ba…"   2 days ago   Up About an hour (healthy)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 5500/tcp   oracle12c

$ docker run -d -p 4040:4040 --net pkngroknet --name ngrok -e NGROK_PROTOCOL="TCP" -e NGROK_AUTH="<myKey>" wernight/ngrok ngrok tcp oracle12c:1521
b0736fdde39e8fced75ea525cd7bb634f083039d4383cb782da9c2ce4557c70f

$ docker logs b0736fdde39e
TCP tunnels are only available after you sign up.
Sign up at: https://dashboard.ngrok.com/signup

If you have already signed up, make sure your authtoken is installed.
Your authtoken is available on your dashboard: https://dashboard.ngrok.com/get-started/your-authtoken

ERR_NGROK_302

Am I doing something wrong?

muripic commented 3 years ago

Same thing happened to me and it's because the entrypoint.sh script is being run with the CMD directive instead of ENTRYPOINT: https://github.com/wernight/docker-ngrok/blob/master/Dockerfile#L46 So when you run docker run ... with a command at the end, such as ngrok tcp oracle12c:1521 (or ngrok http gws:8080 in my case), the CMD in the Dockerfile is overridden and the entrypoint.sh, which adds the auth token to the config file, script does not run. I'm sending a PR to fix this.

muripic commented 3 years ago

Closed pull request because thanks to an error when using it in docker-compose I realized that instead of adding the command you can use NGROK_PORT, like this:

$ docker run -d -p 4040:4040 --net pkngroknet --name ngrok \
  -e NGROK_PROTOCOL="TCP" \
  -e NGROK_AUTH="<myKey>" \
  -e NGROK_PORT="oracle12c:1521" \
  wernight/ngrok 
bekkazy-k commented 2 years ago

You can use auth token like this:

docker run --rm -it --link web_service_container wernight/ngrok ngrok http web_service_container:80 --authtoken [your-token]

drptbl commented 2 years ago

Solution:

  ngrok:
    container_name: ngrok
    image: wernight/ngrok@sha256:f334773a21fdb8c88b320d74ed11f6a2f936840aa85b45e8ddb329823f8e1635
    ports:
      - "4040:4040"
    command: ["ngrok", "http", "novnc:8080", "--authtoken", "${NGROK_AUTH}"]
    depends_on:
      - novnc
    links:
      - novnc
    networks:
      - x11