Skip to content

Instantly share code, notes, and snippets.

@phroggyy
Last active February 7, 2019 11:24
Show Gist options
  • Save phroggyy/de04bd421c165d5216a188ee37a65589 to your computer and use it in GitHub Desktop.
Save phroggyy/de04bd421c165d5216a188ee37a65589 to your computer and use it in GitHub Desktop.
#!/bin/bash
docker ps --format "{{.Names}} {{ .Ports }}" | sed -e 's/_/-/g' | perl -n -e'/^([\w-]+).+:(\d+)->(\d+)/ && print "{\"name\":\"$1\",\"host\":\"$2\",\"container\":\"$3\"}\n"' | jq -r -s 'map(select(.container == "80")) | map(.name + ".test:443 {\n tls self_signed\n proxy / 127.0.0.1:" + .host + "\n}\n") | .[]' > Caddyfile
caddy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment