Comments (5)
Oh there it is, just slipped while reading. :-)
curl $(docker port www_ngrok 4040)/api/tunnels
from docker-ngrok.
And if you want to extract directly the URL from the JSON, you can use this script:
curl -s $(docker port www_ngrok 4040)/api/tunnels/command_line | grep -o '"public_url": *"[^"]*"' | grep -o '"[^"]*"$' | sed -e 's/^"//' -e 's/"$//'
from docker-ngrok.
Parsing JSON with jq is much more readable.
I use it in a docker environment and need the url in the webserver container.
The webserver container has an entrypoint.sh, looking like this:
echo Get ngrok tunnel url...
export WEBHOOK_BASE_URL=$(bash /scripts/ngrok_url.sh)
echo Start webserver...
apache2-foreground
In ngrok_url.sh I have to wait that I can retrieve the url:
function echoUrl {
ngrok_tunnels=$(curl -s http://ngrok:4040/api/tunnels)
index=$(echo $ngrok_tunnels | jq '.tunnels | map(.proto == "https") | index(true)')
echo $ngrok_tunnels | jq -r ".tunnels[$index].public_url"
}
n=0
until [ "$n" -ge 5 ]
do
echoUrl && break
n=$((n+1))
sleep 5
done
from docker-ngrok.
I agree with you, jq
is more readable.
However, jq
is not always available by default on all distros. This is why I've used grep
and sed
instead. Telling my team to install an additional package was not an option for me.
from docker-ngrok.
Related Issues (20)
- Periodically rebuild image HOT 3
- api/tunnels returns empty response when using auth HOT 1
- Does not support spaces in password
- I need help to expose NextCloudPi
- Add NGROK_LOOK_DOMAIN commit to dockerhub HOT 1
- Updating NGROK docker and other questions HOT 1
- Request: image version tag
- authtoken is not respecting in container HOT 1
- Nginx is showing always after generating ngrok url
- Cannot link to webcontainer
- Update? HOT 1
- Inspect Option Support? HOT 1
- multiple ports HOT 1
- transfer maintainership to ngrok? HOT 3
- Add ARM64 (Apple Silicon) support HOT 2
- NGROK_AUTH not working HOT 4
- Add ARM64 (Apple Silicon) support HOT 1
- Ngrok
- ERROR: unknown shorthand flag: 'o' in -ostname=my-app.ngrok.io HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docker-ngrok.