mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 04:56:58 +02:00
sdk_container: better docker / podman detection
In bce3bd9031
, we added support for podman
for building and running the SDK container. The presence of podman is
auto-detected in sdk_container_common.sh. However, podman is preverred
over docker, requiring users to use *sudo* (which podman requires and
docker does not).
This change uses docker when present, podman otherwise. It also improves
podman detection - 'podman' uses argv[0] in its version string, so if
'docker' is a symlink to 'podman', 'podman --version' output uses
'docker'. This broke the SDK container on hosts which have a 'docker'
symlink to 'podman' since 'podman' is then run w/o 'sudo'.
Signed-off-by: Thilo Fromm <thilo@kinvolk.io>
This commit is contained in:
parent
1928852af0
commit
43e8730ffe
@ -11,10 +11,27 @@ sdk_container_common_versionfile="sdk_container/.repo/manifests/version.txt"
|
||||
sdk_container_common_registry="ghcr.io/flatcar-linux"
|
||||
sdk_container_common_env_file="sdk_container/.sdkenv"
|
||||
|
||||
# Check for podman and docker; use docker if present, podman alternatively.
|
||||
# Podman needs 'sudo' since we need privileged containers for the SDK.
|
||||
|
||||
is_podman=false
|
||||
if command -v podman >/dev/null; then
|
||||
is_podman=true
|
||||
# podman is present
|
||||
if command -v docker >/dev/null ; then
|
||||
# docker is present, too
|
||||
if docker help | grep -q -i podman; then
|
||||
# "docker" is actually podman.
|
||||
# NOTE that 'docker --version' does not reliably work for podman detection
|
||||
# since 'podman' uses argv[0] in its version string.
|
||||
# A symlink docker->podman will result in 'podman' using the 'docker' argv[0].
|
||||
is_podman=true
|
||||
fi
|
||||
else
|
||||
# docker is not present
|
||||
is_podman=true
|
||||
fi
|
||||
fi
|
||||
|
||||
docker="docker"
|
||||
if "${is_podman}"; then
|
||||
docker="sudo podman"
|
||||
|
Loading…
Reference in New Issue
Block a user