I’ve found an excellent tiny Docker image for ngrok (wernight/ngrok). From now just using it to handle this blog.
Links at Docker hub and Github.
Some handy snippets. Note, it’s possible to use docker-compose commands, i.e. to check tunnels curl $(docker-compose port ngrok 4040)/api/tunnels
, but I’m using $(docker ps -l -q --filter "name=blog_ngrok")
statement to identify container ID, as it works with both docker-compose “up” and “run” modes and with docker without using docker-compose.
- Logs
BLOG=$(docker ps -l -q --filter "name=blog_ngrok")
docker logs -f $BLOG
- Check open ngrok tunnels
BLOG=$(docker ps -l -q --filter "name=blog_ngrok")
curl $(docker port $BLOG 4040)/api/tunnels
- Open browser window with ngrok http console
BLOG=$(docker ps -l -q --filter "name=blog_ngrok")
open http://$(docker port $BLOG 4040)
It is how docker-compose file looks like for this Jekyll site:
version: '3'
volumes:
ruby-cache:
driver: local
services:
build:
image: jekyll/jekyll
volumes:
- ruby-cache:/usr/local/bundle
- ./:/srv/jekyll
command: jekyll build
jekyll:
image: jekyll/jekyll
volumes:
- ruby-cache:/usr/local/bundle
- ./:/srv/jekyll
command: jekyll serve --incremental --watch
ports:
- 127.0.0.1:4000:4000
ngrok:
image: wernight/ngrok
links:
- jekyll
stdin_open: true
tty: true
ports:
- 127.0.0.1:4040:4040
environment:
- NGROK_REGION=eu
- NGROK_AUTH=...
- NGROK_SUBDOMAIN=...
- NGROK_PROTOCOL=http
- NGROK_PORT=jekyll:4000