2019-04-10 10:59:33 -04:00
|
|
|
package rootless // import "github.com/docker/docker/rootless"
|
2018-10-15 03:52:53 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2021-04-27 03:46:04 -04:00
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/rootless-containers/rootlesskit/pkg/api/client"
|
2018-10-15 03:52:53 -04:00
|
|
|
)
|
|
|
|
|
2022-04-25 07:53:32 -04:00
|
|
|
// RootlessKitDockerProxyBinary is the binary name of rootlesskit-docker-proxy
|
|
|
|
const RootlessKitDockerProxyBinary = "rootlesskit-docker-proxy"
|
2018-10-15 03:52:53 -04:00
|
|
|
|
2019-04-19 03:53:58 -04:00
|
|
|
// RunningWithRootlessKit returns true if running under RootlessKit namespaces.
|
|
|
|
func RunningWithRootlessKit() bool {
|
2022-04-25 07:53:32 -04:00
|
|
|
return os.Getenv("ROOTLESSKIT_STATE_DIR") != ""
|
2018-10-15 03:52:53 -04:00
|
|
|
}
|
2021-04-27 03:46:04 -04:00
|
|
|
|
|
|
|
// GetRootlessKitClient returns RootlessKit client
|
|
|
|
func GetRootlessKitClient() (client.Client, error) {
|
|
|
|
stateDir := os.Getenv("ROOTLESSKIT_STATE_DIR")
|
|
|
|
if stateDir == "" {
|
|
|
|
return nil, errors.New("environment variable `ROOTLESSKIT_STATE_DIR` is not set")
|
|
|
|
}
|
|
|
|
apiSock := filepath.Join(stateDir, "api.sock")
|
|
|
|
return client.New(apiSock)
|
|
|
|
}
|