mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-02-22 07:03:28 +00:00
build/common.sh: fix support for Rootless Docker
In the case of Rootless mode, `docker run` should not be invoked with `--user`. Fix issue 134669 Regression in PR 134510 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
@@ -322,6 +322,10 @@ function kube::build::destroy_container() {
|
||||
"${DOCKER[@]}" rm -f -v "$1" >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
function kube::build::is_docker_rootless() {
|
||||
"${DOCKER[@]}" info --format '{{json .SecurityOptions}}' | grep -q "name=rootless"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Building
|
||||
|
||||
@@ -367,11 +371,12 @@ function kube::build::run_build_command_ex() {
|
||||
|
||||
local -a docker_run_opts=(
|
||||
"--name=${container_name}"
|
||||
"--user=$(id -u):$(id -g)"
|
||||
"--hostname=${HOSTNAME}"
|
||||
"-e=GOPROXY=${GOPROXY}"
|
||||
)
|
||||
|
||||
kube::build::is_docker_rootless || docker_run_opts+=("--user=$(id -u):$(id -g)")
|
||||
|
||||
local detach=false
|
||||
|
||||
[[ $# != 0 ]] || { echo "Invalid input - please specify docker arguments followed by --." >&2; return 4; }
|
||||
|
||||
Reference in New Issue
Block a user