Skip to content

Instantly share code, notes, and snippets.

@andrewodri
Last active November 8, 2019 01:11
Show Gist options
  • Save andrewodri/82f4942f5f50743028c96343f1aecbc6 to your computer and use it in GitHub Desktop.
Save andrewodri/82f4942f5f50743028c96343f1aecbc6 to your computer and use it in GitHub Desktop.
Generate host file compatible syntax from Docker Network
#/bin/bash
docker network inspect $(docker network ls --format '{{ .ID }}') --format '{{ if (index .Labels "media.promoto.host") }}{{ range (split (index .Labels "media.promoto.host") ",") }}{{ printf "%s %s\n" (index $.IPAM.Config 0).Gateway . }}{{ end }}{{ end }}' | sed '/^$/d'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment