diff --git a/cmd/podman/root.go b/cmd/podman/root.go index bc4fccac65..ae9e0cf631 100644 --- a/cmd/podman/root.go +++ b/cmd/podman/root.go @@ -248,6 +248,8 @@ func setupRemoteConnection(podmanConfig *entities.PodmanConfig) string { func persistentPreRunE(cmd *cobra.Command, args []string) error { logrus.Debugf("Called %s.PersistentPreRunE(%s)", cmd.Name(), strings.Join(os.Args, " ")) + checkSupportedCgroups() + // Help, completion and commands with subcommands are special cases, no need for more setup // Completion cmd is used to generate the shell scripts if cmd.Name() == "help" || cmd.Name() == "completion" || cmd.HasSubCommands() { diff --git a/cmd/podman/root_cgroups_linux.go b/cmd/podman/root_cgroups_linux.go new file mode 100644 index 0000000000..fee19873f4 --- /dev/null +++ b/cmd/podman/root_cgroups_linux.go @@ -0,0 +1,18 @@ +//go:build linux + +package main + +import ( + "github.com/sirupsen/logrus" + "go.podman.io/common/pkg/cgroups" +) + +func checkSupportedCgroups() { + unified, err := cgroups.IsCgroup2UnifiedMode() + if err != nil { + logrus.Fatalf("Error determining cgroups mode") + } + if !unified { + logrus.Fatalf("Cgroups v1 not supported") + } +} diff --git a/cmd/podman/root_cgroups_unsupported.go b/cmd/podman/root_cgroups_unsupported.go new file mode 100644 index 0000000000..0ec0c7c1d9 --- /dev/null +++ b/cmd/podman/root_cgroups_unsupported.go @@ -0,0 +1,7 @@ +//go:build !linux + +package main + +func checkSupportedCgroups() { + // NOP on Non Linux +}