1
0

Fix case where both docker and podman are installed, but docker is not podman alias

This commit is contained in:
dump_stack() 2023-02-11 08:52:49 +00:00
parent 55032f07af
commit a9db750ea5
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC

View File

@ -97,8 +97,7 @@ func (cmd *KernelDockerRegenCmd) Run(kernelCmd *KernelCmd, g *Globals) (err erro
} }
args := []string{"build"} args := []string{"build"}
_, err = exec.Command("which", "podman").CombinedOutput() if dockerIsPodman() {
if err == nil {
args = append(args, "--squash-all") args = append(args, "--squash-all")
} }
args = append(args, "-t", d.ContainerName, imagePath) args = append(args, "-t", d.ContainerName, imagePath)
@ -353,8 +352,7 @@ func generateBaseDockerImage(registry string, commands []config.DockerCommand,
} }
args := []string{"build"} args := []string{"build"}
_, err = exec.Command("which", "podman").CombinedOutput() if dockerIsPodman() {
if err == nil {
args = append(args, "--squash-all") args = append(args, "--squash-all")
} }
args = append(args, "-t", sk.DockerName(), imagePath) args = append(args, "-t", sk.DockerName(), imagePath)
@ -427,8 +425,7 @@ func dockerImageAppend(sk config.KernelMask, pkgname string) (err error) {
} }
args := []string{"build"} args := []string{"build"}
_, err = exec.Command("which", "podman").CombinedOutput() if dockerIsPodman() {
if err == nil {
args = append(args, "--squash-all") args = append(args, "--squash-all")
} }
args = append(args, "-t", sk.DockerName(), imagePath) args = append(args, "-t", sk.DockerName(), imagePath)
@ -766,3 +763,11 @@ func generateKernels(km config.KernelMask, registry string,
} }
return return
} }
func dockerIsPodman() bool {
output, err := exec.Command("docker", "version").CombinedOutput()
if err != nil {
return false
}
return strings.Contains(string(output), "podman")
}