github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/proc/docker.go (about)

     1  package proc
     2  
     3  import (
     4  	"os"
     5  )
     6  
     7  var runningInContainer bool //nolint:gochecknoglobals // this is a constant
     8  
     9  func init() {
    10  	_, err := os.Stat("/.dockerenv")
    11  	runningInContainer = err == nil
    12  }
    13  
    14  // RunningInContainer returns true if the current process runs from inside a docker container.
    15  func RunningInContainer() bool {
    16  	return runningInContainer
    17  }