summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild-docker.sh13
1 files changed, 9 insertions, 4 deletions
diff --git a/build-docker.sh b/build-docker.sh
index a7f18f1..b3995d5 100755
--- a/build-docker.sh
+++ b/build-docker.sh
@@ -4,10 +4,15 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
BUILD_OPTS="$*"
-DOCKER="docker"
-
-if ! ${DOCKER} ps >/dev/null 2>&1; then
- DOCKER="sudo docker"
+# Allow user to override docker command
+DOCKER=${DOCKER:-docker}
+
+# Ensure that default docker command is not set up in rootless mode
+if \
+ ! ${DOCKER} ps >/dev/null 2>&1 || \
+ ${DOCKER} info 2>/dev/null | grep -q rootless \
+; then
+ DOCKER="sudo ${DOCKER}"
fi
if ! ${DOCKER} ps >/dev/null; then
echo "error connecting to docker:"