github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/container/utils.go (about) 1 // Copyright 2016 Canonical Ltd. 2 // Licensed under the AGPLv3, see LICENCE file for details. 3 4 package container 5 6 import ( 7 "os/exec" 8 "runtime" 9 ) 10 11 var RunningInContainer = func() bool { 12 if runtime.GOOS != "linux" { 13 return false 14 } 15 16 /* running-in-container is in init-scripts-helpers, and is smart enough 17 * to ask both systemd and upstart whether or not they know if the task 18 * is running in a container. 19 */ 20 cmd := exec.Command("running-in-container") 21 return cmd.Run() == nil 22 } 23 24 func ContainersSupported() bool { 25 return !RunningInContainer() 26 }