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