From a9db750ea546ae3d4cd84b0aadcd6ca3f63768e8 Mon Sep 17 00:00:00 2001 From: Mikhail Klementev Date: Sat, 11 Feb 2023 08:52:49 +0000 Subject: [PATCH] Fix case where both docker and podman are installed, but docker is not podman alias --- kernel.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel.go b/kernel.go index 0c59bf9..d858d42 100644 --- a/kernel.go +++ b/kernel.go @@ -97,8 +97,7 @@ func (cmd *KernelDockerRegenCmd) Run(kernelCmd *KernelCmd, g *Globals) (err erro } args := []string{"build"} - _, err = exec.Command("which", "podman").CombinedOutput() - if err == nil { + if dockerIsPodman() { args = append(args, "--squash-all") } args = append(args, "-t", d.ContainerName, imagePath) @@ -353,8 +352,7 @@ func generateBaseDockerImage(registry string, commands []config.DockerCommand, } args := []string{"build"} - _, err = exec.Command("which", "podman").CombinedOutput() - if err == nil { + if dockerIsPodman() { args = append(args, "--squash-all") } args = append(args, "-t", sk.DockerName(), imagePath) @@ -427,8 +425,7 @@ func dockerImageAppend(sk config.KernelMask, pkgname string) (err error) { } args := []string{"build"} - _, err = exec.Command("which", "podman").CombinedOutput() - if err == nil { + if dockerIsPodman() { args = append(args, "--squash-all") } args = append(args, "-t", sk.DockerName(), imagePath) @@ -766,3 +763,11 @@ func generateKernels(km config.KernelMask, registry string, } return } + +func dockerIsPodman() bool { + output, err := exec.Command("docker", "version").CombinedOutput() + if err != nil { + return false + } + return strings.Contains(string(output), "podman") +}