[PATCH] kas-container: Fix podman detection

9 views
Skip to first unread message

Diogo Silva

unread,
Apr 18, 2026, 12:37:17 PMApr 18
to kas-...@googlegroups.com, Diogo Silva
When "-v" is ran on podman, whatever is the name of the executable will
be printed out. In the case of symlinks this will print out whatever is
the name of the symlink. If docker compatibility is achieved via
symlink, then "docker -v" will print out "docker version x.x.x" and kas
will report unknown engine.
Since the only supported engines are docker and podman, when "docker -v"
doesn't show "Docker ..." we can just check for the podman command to
know if the machine has it available.

Signed-off-by: Diogo Silva <diogomp...@gmail.com>
---
kas-container | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/kas-container b/kas-container
index 2241c31..1249260 100755
--- a/kas-container
+++ b/kas-container
@@ -322,21 +322,9 @@ setup_kas_dirs
KAS_CONTAINER_ENGINE="${KAS_CONTAINER_ENGINE:-${KAS_DOCKER_ENGINE}}"
if [ -z "${KAS_CONTAINER_ENGINE}" ]; then
# Try to auto-detect a container engine
- if command -v docker >/dev/null; then
- case $(docker -v 2>/dev/null) in
- podman*)
- # The docker command is an alias for podman
- KAS_CONTAINER_ENGINE=podman
- ;;
- Docker*)
- # The docker command is the real docker
- KAS_CONTAINER_ENGINE=docker
- ;;
- *)
- # The docker command is an unknown engine
- fatal_error "docker command found, but unknown engine detected"
- esac
- elif command -v podman >/dev/null; then
+ if command -v docker >/dev/null 2>&1 && docker -v 2>/dev/null | grep -q '^Docker'; then
+ KAS_CONTAINER_ENGINE=docker
+ elif command -v podman >/dev/null 2>&1; then
KAS_CONTAINER_ENGINE=podman
else
fatal_error "no container engine found, need docker or podman"
--
2.51.2

Jan Kiszka

unread,
Apr 19, 2026, 4:19:09 PMApr 19
to Diogo Silva, kas-...@googlegroups.com
On 18.04.26 18:36, Diogo Silva wrote:
> When "-v" is ran on podman, whatever is the name of the executable will
> be printed out. In the case of symlinks this will print out whatever is
> the name of the symlink. If docker compatibility is achieved via
> symlink, then "docker -v" will print out "docker version x.x.x" and kas
> will report unknown engine.
> Since the only supported engines are docker and podman, when "docker -v"
> doesn't show "Docker ..." we can just check for the podman command to
> know if the machine has it available.

We only support the two, but we do need to know if docker is actually
podman because there are differences the two engines, and we must start
in podman mode if that is the backing engine.

So, the main issue is a link-based docker emulation is not qualified as
podman. How about detecting this case then by testing for docker being a
symlink to podman?

Jan
Siemens AG, Foundational Technologies
Linux Expert Center

Diogo Silva

unread,
Apr 27, 2026, 10:25:43 AM (13 days ago) Apr 27
to Jan Kiszka, kas-...@googlegroups.com
Hey,

I do understand the need to differentiate the actual engine. But in my
view there is not really a point in checking if there is "docker" as a
symlink to podman, because in that case there will also be the
"podman" binary.
So, in the case where

Docker is installed -> Docker is selected due to the condition " if
command -v docker >/dev/null 2>&1 && docker -v 2>/dev/null | grep -q
'^Docker' "
Docker is a symlink to Podman -> the previous condition fails but "
elif command -v podman >/dev/null 2>&1; then " succeeds and sets
podman as the engine
Podman is installed -> everything goes the same as the previous case
None are installed -> fatal_error

So, as I see it, this way both engines are reliable detected, and the
code is even simplified.

Please let me know if my thinking is flawed in any way, and if that is
the case I can come up with a way of detecting the symlink.

BR,
Diogo

Jan Kiszka

unread,
Apr 27, 2026, 10:32:06 AM (13 days ago) Apr 27
to Diogo Silva, kas-...@googlegroups.com
On 27.04.26 16:25, Diogo Silva wrote:
> Hey,
>
> I do understand the need to differentiate the actual engine. But in my
> view there is not really a point in checking if there is "docker" as a
> symlink to podman, because in that case there will also be the
> "podman" binary.
> So, in the case where
>
> Docker is installed -> Docker is selected due to the condition " if
> command -v docker >/dev/null 2>&1 && docker -v 2>/dev/null | grep -q
> '^Docker' "
> Docker is a symlink to Podman -> the previous condition fails but "
> elif command -v podman >/dev/null 2>&1; then " succeeds and sets
> podman as the engine
> Podman is installed -> everything goes the same as the previous case
> None are installed -> fatal_error
>
> So, as I see it, this way both engines are reliable detected, and the
> code is even simplified.
>
> Please let me know if my thinking is flawed in any way, and if that is
> the case I can come up with a way of detecting the symlink.

No, you are correct, I missed the small detail that the grep is checking
case-sensitively here.

Thanks, applied.

Jan
Reply all
Reply to author
Forward
0 new messages