pyngrok
Containerized pyngrok for local tunneling and webhook testing
9.5K

pyngrok is a Python wrapper for ngrok that manages its own binary,
making ngrok available via a convenient Python API, the command line, and (from this repo) via pre-built
container images, available on Docker Hub.
ngrok is a reverse proxy that opens secure tunnels from public URLs to localhost. It's perfect
for rapid development (test webhooks, demo local websites, enable SSH access), establishing ingress to external
networks and devices, building production APIs (traffic policies, OAuth, load balancing), and more. And
it's made even more powerful with native Python integration through the pyngrok client.
To launch the container in to a Python shell, run:
docker run -e NGROK_AUTHTOKEN=$NGROK_AUTHTOKEN -it alexdlaird/pyngrok
If you want to start in a bash shell instead of Python, you can launch the container with:
docker run -e NGROK_AUTHTOKEN=$NGROK_AUTHTOKEN -it alexdlaird/pyngrok /bin/bash
The pyngrok-example-flask repository also includes a
Dockerfile and make commands to run it, if you would like to see a complete example.
ngrok will look for its config file in this container at /root/.config/ngrok/ngrok.yml. If you want to provide a
custom config file, specify a mount to this file when launching the container.
docker run -v ./ngrok.yml:/root/.config/ngrok/ngrok.yml -it alexdlaird/pyngrok
If you want to use ngrok's web inspector, be sure to expose its port. Ensure whatever config file you use
sets web_addr: 0.0.0.0:4040 (the config provisioned in the
pre-built images already does this).
docker run --env-file .env -p 4040:4040 -it alexdlaird/pyngrok
Here is an example of how you could instantiate the container with docker-compose.yml, where you also want a given
Python script to run on startup:
services:
ngrok:
image: alexdlaird/pyngrok
env_file: ".env"
command:
- "python /root/my-script.py"
volumes:
- ./my-script.py:/root/my-script.py
ports:
- 4040:4040
Then launch it with:
docker compose up -d
For more advanced usage of pyngrok, its official documentation is available
on Read the Docs.
The pyngrok package puts the default ngrok binary on your path in the container, so all features of ngrok are
also available on the command line.
docker run -e NGROK_AUTHTOKEN=$NGROK_AUTHTOKEN -it alexdlaird/pyngrok ngrok http 80
For details on how to fully leverage ngrok from the command line,
see ngrok's official documentation.
Images are multi-architectural, and tagged with the following format:
alexdlaird/pyngrok:py$PYTHON_VERSION-$DISTRO-$VERSION
The following tag variants are available:
$PYTHON_VERSION has 3.9 through 3.13
latest$DISTRO has alpine, or Debian flavors of bookworm, slim-bookworm
slim-bookworm$VERSION matches the container version in table below
latestThe first three numbers of the container version correspond to the version of pyngrok it has installed, and you can
just use the pyngrok version to grab the latest tagged image for that release.
This table shows the ngrok version that is published in each image:
| Container Version | Agent Version |
|---|---|
| 8.1.2.0 | 3.39.1 |
| 8.1.1.0 | 3.39.0 |
| 8.1.0.0 | 3.38.0 |
| 8.0.0.0 | 3.37.6 |
| 7.5.1.0 | 3.37.1 |
| 7.5.0.1 | 3.36.1 |
| 7.5.0.0 | 3.33.0 |
| 7.4.0.0 | 3.29.0 |
| 7.3.0.1 | 3.26.0 |
| 7.3.0.0 | 3.25.1 |
| 7.2.12.2 | 3.25.0 |
| 7.2.12.1 | 3.24.0 |
| 7.2.12.0 | 3.23.3 |
Content type
Image
Digest
sha256:d39d7c175…
Size
73.5 MB
Last updated
3 months ago
docker pull alexdlaird/pyngrok