dockerfile - 将包添加到私有存储库中的 ubi 最小基础镜像中

问题描述 投票:0回答:1

我正在尝试从 Nodejs 最小化构建我的 docker 镜像作为基础镜像。
Nodejs Minimal 没有 Shadow-utils,我需要添加用户组和用户。
我正在使用的 NodeJS 最小映像托管在私有存储库中,并且此存储库不托管 Shadow-utils 包。
如何通过我的 dockerfile 在 NodeJS 最小映像中安装 Shadow-utils?
我在我的 dockerfile 中尝试了以下操作

FROM private.repo.com/node:20.9.0_ubi9

RUN microdnf install shadow-utils -y && \
    microdnf clean all

当我运行

docker build -t myimage:mytag .
时,它无法说出以下内容。不确定这是权限问题还是存储库问题。

 => ERROR [6/7] RUN microdnf install shadow-utils -y && microdnf clean all            0.4s
------
 > [6/7] RUN microdnf install shadow-utils -y && microdnf clean all:
0.289 error: Failed to create: /var/cache/yum/metadata
------
dockerfile:10
--------------------
   9 |     
  10 | >>> RUN microdnf install shadow-utils -y && \
  11 | >>> microdnf clean all
  12 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c microdnf install shadow-utils -y && microdnf clean all" did not complete successfully: exit code: 1
docker dockerfile redhat rhel ubi
1个回答
0
投票

这可能是权限问题。请尝试这个并检查:

FROM private.repo.com/node:20.9.0_ubi9

# set permissions
RUN mkdir -p /var/cache/yum && \
    chown root:root /var/cache/yum && \
    chmod 755 /var/cache/yum

RUN microdnf install shadow-utils -y && \
    microdnf clean all
© www.soinside.com 2019 - 2024. All rights reserved.