From bf656ca53cf66f3b03fd89dbdce4fd04bd585fd5 Mon Sep 17 00:00:00 2001 From: rpier1 <59652629+rpier1@users.noreply.github.com> Date: Wed, 8 Jan 2020 14:31:13 +0100 Subject: [PATCH] ensure binfmt-support is installed --- build-docker.sh | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index 79b68d4..c4a572c 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -3,11 +3,23 @@ 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" +SUDO='' +if [ $EUID != 0 ]; then + SUDO='sudo' fi + +function install_binfmt_support { + local binfmtSupport="binfmt-support" + if ! dpkg -s $binfmtSupport &>/dev/null; then + echo "please install $binfmtSupport with this command: $SUDO apt-get install $binfmtSupport" + exit 1 + fi +} + +install_binfmt_support + +DOCKER="$SUDO docker" + if ! ${DOCKER} ps >/dev/null; then echo "error connecting to docker:" ${DOCKER} ps