nomad-port-forward is a simple utility to forward ports from a Nomad job to a local machine.
Thanks to @picatz for showing how to do this in hashicorp/nomad#6925
brew install Mongey/tap/nomad-port-forwardgo install github.com/Mongey/nomad-port-forward/cmd/nomad-port-forward@latestDownload a pre-built binary from the releases page.
nomad-port-forward -alloc-id <alloc-id> -task nginx -p 8080:localhost:80nomad-port-forward embeds a tiny static Go TCP proxy binary (tcpfwd) for linux/amd64 and linux/arm64. At runtime it:
- Detects the target allocation's architecture via
nomad alloc exec ... uname -m - Uploads the matching
tcpfwdbinary into the allocation at/tmp/tcpfwd - For each local connection, runs
nomad alloc exec ... /tmp/tcpfwd addr:portto proxy traffic
No package manager, network access, or root permissions are needed inside the allocation.