Skip to content

Commit

Permalink
support command without sudo
Browse files Browse the repository at this point in the history
  • Loading branch information
bamarni committed Feb 9, 2016
1 parent f4be7b5 commit aab6d09
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion docker-machine-dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ func lookup(w dns.ResponseWriter, r *dns.Msg) {

domLevels := strings.Split(q.Name, ".")
machine := domLevels[len(domLevels)-3]
stdoutBytes, err := exec.Command("sudo", "-u", user, "docker-machine", "ip", machine).Output()

var stdoutBytes []byte
var err error

if user == "" {
stdoutBytes, err = exec.Command("docker-machine", "ip", machine).Output()
} else {
stdoutBytes, err = exec.Command("sudo", "-u", user, "docker-machine", "ip", machine).Output()
}

if err != nil {
log.Printf("No IP found for machine '%s'", machine)
continue
Expand Down

0 comments on commit aab6d09

Please sign in to comment.