github.com/rawahars/moby@v24.0.4+incompatible/pkg/rootless/rootless.go (about) 1 package rootless // import "github.com/docker/docker/pkg/rootless" 2 3 import ( 4 "os" 5 "path/filepath" 6 7 "github.com/pkg/errors" 8 "github.com/rootless-containers/rootlesskit/pkg/api/client" 9 ) 10 11 // RootlessKitDockerProxyBinary is the binary name of rootlesskit-docker-proxy 12 const RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy" 13 14 // RunningWithRootlessKit returns true if running under RootlessKit namespaces. 15 func RunningWithRootlessKit() bool { 16 return os.Getenv("ROOTLESSKIT_STATE_DIR") != "" 17 } 18 19 // GetRootlessKitClient returns RootlessKit client 20 func GetRootlessKitClient() (client.Client, error) { 21 stateDir := os.Getenv("ROOTLESSKIT_STATE_DIR") 22 if stateDir == "" { 23 return nil, errors.New("environment variable `ROOTLESSKIT_STATE_DIR` is not set") 24 } 25 apiSock := filepath.Join(stateDir, "api.sock") 26 return client.New(apiSock) 27 }