Skip to content

Instantly share code, notes, and snippets.

@hectorgool
Last active November 2, 2016 19:12
Show Gist options
  • Select an option

  • Save hectorgool/c01ed842f75297c011591b1af92dec55 to your computer and use it in GitHub Desktop.

Select an option

Save hectorgool/c01ed842f75297c011591b1af92dec55 to your computer and use it in GitHub Desktop.
Get doker ip container and print
/*
http://stackoverflow.com/questions/26411594/executing-docker-command-using-golang-exec-fails
*/
package main
import (
"fmt"
"os/exec"
)
func main() {
cmdStr := "docker inspect --format '{{ .NetworkSettings.IPAddress }}' elasticsearch"
out, _ := exec.Command("/bin/sh", "-c", cmdStr).Output()
fmt.Printf("%s", out)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment