From 73366da9f9ee2c53cfc9f702f04a59740994c7be Mon Sep 17 00:00:00 2001 From: Jakub Ledworowski Date: Wed, 24 Apr 2024 15:35:36 +0200 Subject: [PATCH] build: Fix tarball not building correctly in docker When docker is installed on the host system using script from https://get.docker.com/ it automatically creates a docker group with gid=999. Then during docker build process of tarball, eg. make qemu-tdx-experimental-tarball docker is also installed inside the image with the same script, which also automatically adds docker group with gid=999. Then, the build tries to add a new group docker_on_host with gid=999, which already exists, which breaks the build. Signed-off-by: Jakub Ledworowski --- .../packaging/kata-deploy/local-build/dockerbuild/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile b/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile index f4ba5cc60e..d58e542abe 100644 --- a/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile +++ b/tools/packaging/kata-deploy/local-build/dockerbuild/Dockerfile @@ -39,8 +39,8 @@ ARG HOST_DOCKER_GID RUN if [ ${IMG_USER} != "root" ]; then sed -i -e "/:${GID}:/d" /etc/group; groupadd --gid=${GID} ${IMG_USER};fi RUN if [ ${IMG_USER} != "root" ]; then adduser ${IMG_USER} --uid=${UID} --gid=${GID};fi -RUN if [ ${IMG_USER} != "root" ] && [ ! -z ${HOST_DOCKER_GID} ]; then groupadd --gid=${HOST_DOCKER_GID} docker_on_host;fi -RUN if [ ${IMG_USER} != "root" ] && [ ! -z ${HOST_DOCKER_GID} ]; then usermod -a -G docker_on_host ${IMG_USER};fi +RUN if [ ${IMG_USER} != "root" ] && [ ! -z ${HOST_DOCKER_GID} ] && [ ! $(getent group | grep :${HOST_DOCKER_GID}:) ]; then groupadd --gid=${HOST_DOCKER_GID} docker_on_host;fi +RUN if [ ${IMG_USER} != "root" ] && [ ! -z ${HOST_DOCKER_GID} ]; then usermod -a -G ${HOST_DOCKER_GID} ${IMG_USER};fi RUN sh -c "echo '${IMG_USER} ALL=NOPASSWD: ALL' >> /etc/sudoers" RUN if [ "${ARCH}" != "$(uname -m)" ] && [ "${ARCH}" == "s390x" ]; then sed -i 's/^deb/deb [arch=amd64]/g' /etc/apt/sources.list && \