When using the isar (privileged) mode and having a rootless docker
context, we must switch to the system docker (default) context.
Previously, we just assumed that the system docker is running under a
well-known path, but we can do better and query the default context for
the path of the docker socket.
In most cases this should not make any difference, but it allows us to
avoid hard-coded path based on assumptions. We further output the
chosen path in the debug message.
Signed-off-by: Felix Moessbauer <
felix.mo...@siemens.com>
---
kas-container | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kas-container b/kas-container
index 9afab2557..2241c3136 100755
--- a/kas-container
+++ b/kas-container
@@ -160,8 +160,9 @@ enable_isar_mode()
export PATH="${PATH}:/usr/sbin"
elif [ "${KAS_DOCKER_ROOTLESS}" = "1" ]; then
prepare_sudo_cmd
- export DOCKER_HOST="${DOCKER_HOST:-unix:///var/run/docker.sock}"
- debug "kas-isar does not support rootless docker. Using system docker"
+ DOCKER_HOST_DEFAULT="$(docker context inspect default --format '{{.Endpoints.docker.Host}}')"
+ export DOCKER_HOST="${DOCKER_HOST:-$DOCKER_HOST_DEFAULT}"
+ debug "kas-isar does not support rootless docker. Using system docker in $DOCKER_HOST"
# force use of well-known system docker socket
KAS_CONTAINER_COMMAND="${_KAS_SUDO_CMD} ${KAS_CONTAINER_COMMAND}"
KAS_DOCKER_ROOTLESS=0
--
2.51.0