0%
December 18, 2024

Multiple Ngroks Via Docker Compose

docker

Below we registered two accounts in ngrok and therefore obtained two NGROK_AUTHTOKEN's.

It forwards our localhost:8080 and localhost:9090 as an https endpoints which are reachable in public.

version: '3.8'

services:
  ngrok1:
    image: ngrok/ngrok:latest
    environment:
      - NGROK_AUTHTOKEN=token1
      - NGROK_LOG=stdout
      - NGROK_LOG_LEVEL=info
    command:
      - "http"
      - "--log=stdout"
      - "host.docker.internal:9090"
    ports:
      - "4040:4040"  # Web interface for ngrok1
    extra_hosts:
      - "host.docker.internal:host-gateway"

  ngrok2:
    image: ngrok/ngrok:latest
    environment:
      - NGROK_AUTHTOKEN=token2
      - NGROK_LOG=stdout
      - NGROK_LOG_LEVEL=info
    command:
      - "http"
      - "--log=stdout"
      - "host.docker.internal:8080"
    ports:
      - "4041:4040"  # Web interface for ngrok2
    extra_hosts:
      - "host.docker.internal:host-gateway"