Check that docker is not set up in rootless mode (#679)
Mounting binfmt_misc inside the container requires root rights. If "docker info" indicates rootless mode then fall back to "sudo docker". Allow the user to override the docker command with the DOCKER by setting the environment variable.
This commit is contained in:
parent
f2d385517c
commit
cf40e4b299
@ -4,10 +4,15 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|||||||
|
|
||||||
BUILD_OPTS="$*"
|
BUILD_OPTS="$*"
|
||||||
|
|
||||||
DOCKER="docker"
|
# Allow user to override docker command
|
||||||
|
DOCKER=${DOCKER:-docker}
|
||||||
|
|
||||||
if ! ${DOCKER} ps >/dev/null 2>&1; then
|
# Ensure that default docker command is not set up in rootless mode
|
||||||
DOCKER="sudo docker"
|
if \
|
||||||
|
! ${DOCKER} ps >/dev/null 2>&1 || \
|
||||||
|
${DOCKER} info 2>/dev/null | grep -q rootless \
|
||||||
|
; then
|
||||||
|
DOCKER="sudo ${DOCKER}"
|
||||||
fi
|
fi
|
||||||
if ! ${DOCKER} ps >/dev/null; then
|
if ! ${DOCKER} ps >/dev/null; then
|
||||||
echo "error connecting to docker:"
|
echo "error connecting to docker:"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user