Skip to content

Commit

Permalink
Refactor userns_remap.go to use docker info to identify userns
Browse files Browse the repository at this point in the history
  • Loading branch information
vasrem committed Nov 29, 2018
1 parent 4249aea commit 8775a6d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/docker/userns_remap.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ import (

// UsernsRemap checks if userns-remap is enabled in dockerd
func UsernsRemap() bool {
cmd := exec.Command("cat", "/etc/docker/daemon.json")
cmd := exec.Command("docker", "info", "--format", "'{{json .SecurityOptions}}'")
lines, err := exec.CombinedOutputLines(cmd)
if err != nil {
return false
}
for _, l := range lines {
if strings.Contains(l, "userns-remap") {
if len(lines) > 0 {
if strings.Contains(lines[0], "name=userns") {
return true
}
}
Expand Down

0 comments on commit 8775a6d

Please sign in to comment.