1
0

Make docker permissions errors more obvious

This commit is contained in:
dump_stack() 2019-07-10 22:08:04 +00:00
parent 133b7a9b03
commit 6156947406
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

17
main.go
View File

@ -61,6 +61,14 @@ func checkRequiredUtils() (err error) {
return return
} }
func checkDockerPermissions() (err error) {
output, err := exec.Command("docker", "ps").CombinedOutput()
if err != nil {
err = fmt.Errorf(string(output))
}
return
}
func main() { func main() {
app := kingpin.New( app := kingpin.New(
"out-of-tree", "out-of-tree",
@ -140,6 +148,15 @@ func main() {
log.Fatalln(err) log.Fatalln(err)
} }
err = checkDockerPermissions()
if err != nil {
log.Println(err)
log.Println("You have two options:")
log.Println("\t1. Add user to group docker;")
log.Println("\t2. Run out-of-tree with sudo.")
os.Exit(1)
}
if !exists(usr.HomeDir + "/.out-of-tree/images") { if !exists(usr.HomeDir + "/.out-of-tree/images") {
log.Println("No ~/.out-of-tree/images: " + log.Println("No ~/.out-of-tree/images: " +
"Probably you need to run `out-of-tree bootstrap`" + "Probably you need to run `out-of-tree bootstrap`" +