Search code examples
dockerdockerfilengrok

Cannot add Ngrok command in Dockerfile


I'm trying to add RUN ngrok config add-authoken command in Dockerfile. From the error output, it seems like ngrok config command itself is working fine but for some reason it's not recognizing the add-authtoken part.

My Dockerfile:

FROM node:16

ARG NGROK_TOKEN

RUN npm install -g \
   ngrok \
   pm2 \
   typescript

WORKDIR /app

RUN ngrok config add-authtoken ${NGROK_TOKEN} # Here is where error occurs.

# ...content continues...

The docker build command:

docker build --file="./Dockerfile" --build-arg="NGROK_TOKEN=abc" .

The error:

=> ERROR [ 4/11] RUN ngrok config add-authtoken abc                  0.8s
------
 > [ 4/11] RUN ngrok config add-authtoken abc:
#7 0.736 NAME:
#7 0.736    ngrok - tunnel local ports to public URLs and inspect traffic
#7 0.736
#7 0.736 DESCRIPTION:
#7 0.736     ngrok exposes local networked services behinds NATs and firewalls to the
#7 0.736     public internet over a secure tunnel. Share local websites, build/test
#7 0.736     webhook consumers and self-host personal services.
#7 0.736     Detailed help for each command is available with 'ngrok help <command>'.
#7 0.736     Open http://localhost:4040 for ngrok's web interface to inspect traffic.
#7 0.736
#7 0.736 EXAMPLES:
#7 0.736     ngrok http 80                    # secure public URL for port 80 web server
#7 0.736     ngrok http -subdomain=baz 8080   # port 8080 available at baz.ngrok.io
#7 0.737     ngrok http foo.dev:80            # tunnel to host:port instead of localhost
#7 0.737     ngrok http https://localhost     # expose a local https server
#7 0.737     ngrok tcp 22                     # tunnel arbitrary TCP traffic to port 22
#7 0.737     ngrok tls -hostname=foo.com 443  # TLS traffic for foo.com to port 443
#7 0.737     ngrok start foo bar baz          # start tunnels from the configuration file
#7 0.737
#7 0.737 VERSION:
#7 0.737    2.3.41
#7 0.737
#7 0.737 AUTHOR:
#7 0.737   inconshreveable - <[email protected]>
#7 0.737
#7 0.737 COMMANDS:
#7 0.737    authtoken   save authtoken to configuration file
#7 0.737    credits     prints author and licensing information
#7 0.737    http                start an HTTP tunnel
#7 0.737    start       start tunnels by name from the configuration file
#7 0.737    tcp         start a TCP tunnel
#7 0.737    tls         start a TLS tunnel
#7 0.737    update      update ngrok to the latest version
#7 0.737    version     print the version string
#7 0.737    help                Shows a list of commands or help for one command
#7 0.737
#7 0.737 ERROR:  Unrecognized command: config
------
executor failed running [/bin/sh -c ngrok config add-authtoken ${NGROK_TOKEN}]: exit code: 1

Solution

  • The command you are running is for the v3.X Agent, but you are running a v2.3.41 agent.