kas-container: Fix engine detection when docker is an alias for podman

The current detection mechanism assumes that if the docker command
is available the engine behind is also docker. In fact nowadays a
lot of people use /usr/bin/docker as an alias for podman. In that
case the script expects a docker engine and misses to use
podman-specific settings.

To fix this, run "docker -v" and check if the output indicates a
podman engine or a real docker engine. Otherwise error out as the
enginge is not supported.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Frieder Schrempf 2023-01-09 12:57:40 +01:00 committed by Jan Kiszka
parent f5655dcb0c
commit f3521f82fa

View File

@ -154,7 +154,20 @@ 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
KAS_CONTAINER_ENGINE=docker
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
echo "$0: docker command found, but unknown engine detected" >&2
exit 1
esac
elif command -v podman >/dev/null; then
KAS_CONTAINER_ENGINE=podman
else