mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-21 20:08:54 +00:00
While running make as non-privileged user, the make errors out with the following message: "INFO: Build cloud-hypervisor enabling the following features: tdx Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/create?fromImage=cloudhypervisor%2Fdev&tag=20220524-0": dial unix /var/run/docker.sock: connect: permission denied" Even though the user may be part of docker group, the clh build from source does a docker in docker build. It is necessary for the user of the nested container to be part of docker build for the build to succeed. Fixes #4594 Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
47 lines
1.3 KiB
Bash
Executable File
47 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Copyright (c) 2018-2021 Intel Corporation
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
set -o errexit
|
|
set -o nounset
|
|
set -o pipefail
|
|
set -o errtrace
|
|
|
|
script_dir=$(dirname "$(readlink -f "$0")")
|
|
kata_dir=$(realpath "${script_dir}/../../../../")
|
|
kata_deploy_create="${script_dir}/kata-deploy-binaries.sh"
|
|
uid=$(id -u ${USER})
|
|
gid=$(id -g ${USER})
|
|
|
|
if [ "${script_dir}" != "${PWD}" ]; then
|
|
ln -sf "${script_dir}/build" "${PWD}/build"
|
|
fi
|
|
|
|
# This is the gid of the "docker" group on host. In case of docker in docker builds
|
|
# for some of the targets (clh builds from source), the nested container user needs to
|
|
# be part of this group.
|
|
docker_gid=$(getent group docker | cut -d: -f3 || { echo >&2 "Missing docker group, docker needs to be installed" && false; })
|
|
|
|
# If docker gid is the effective group id of the user, do not pass it as
|
|
# an additional group.
|
|
if [ ${docker_gid} == ${gid} ]; then
|
|
docker_gid=""
|
|
fi
|
|
|
|
docker build -q -t build-kata-deploy \
|
|
--build-arg IMG_USER="${USER}" \
|
|
--build-arg UID=${uid} \
|
|
--build-arg GID=${gid} \
|
|
--build-arg HOST_DOCKER_GID=${docker_gid} \
|
|
"${script_dir}/dockerbuild/"
|
|
|
|
docker run \
|
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
|
--env USER=${USER} -v "${kata_dir}:${kata_dir}" \
|
|
--rm \
|
|
-w ${script_dir} \
|
|
build-kata-deploy "${kata_deploy_create}" $@
|