mirror of
https://github.com/kubernetes/kubernetes.git
synced 2026-02-03 20:40:26 -05: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:
parent
e2453c503e
commit
f6e2ea7b96
1 changed files with 6 additions and 1 deletions
|
|
@ -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; }
|
||||
|
|
|
|||
Loading…
Reference in a new issue