"groupadd: Command not found" 在 docker 容器中,即使我安装了它并且我是 root

"groupadd: Command not found" in docker container even though I install it and I am root

我有以下要构建的 Dockerfile。它基本上只是普通的 jboss/wildfly 基本映像,但使用 amazonlinux 而不是 centOS 构建。

构建错误出现在行 "groupadd: Command not found"

第一次发生这种情况后,我添加了 "epel" 存储库并尝试手动安装它,如您在第一个 运行 指令中所见。我已经阅读了一些论坛,似乎有时当您不是 运行 作为 root 时,您会收到该错误消息。我做了 "whoami" 并且我是 运行 作为 root,所以这应该不是问题。

有人知道为什么我仍然收到错误消息吗?

FROM amazonlinux:2017.03

# Install packages necessary to run EAP
RUN yum-config-manager --enable epel && yum update -y && yum -y install      groupadd xmlstarlet saxon augeas bsdtar unzip && yum clean all

# Create a user and group used to launch processes
# The user ID 1000 is the default for the first "regular" user on Fedora/RHEL,
# so there is a high chance that this ID will be equal to the current user
# making it easier to use volumes (no permission issues)
RUN groupadd -r jboss -g 1000 && useradd -u 1000 -r -g jboss -m -d /opt/jboss -s /sbin/nologin -c "JBoss user" jboss && \
chmod 755 /opt/jboss

# Set the working directory to jboss' user home directory
WORKDIR /opt/jboss

# Specify the user which should be used to execute all commands below
USER jboss

提前致谢!

你的问题是 groupadd 不是一个包,所以你不能像你现在尝试的那样安装它。

您可以安装 shadow-utils。x86_64,这将使 groupadd 命令可用。

yum install shadow-utils.x86_64 -y

或修改您的 "RUN" 行:

RUN yum-config-manager --enable epel && yum update -y && yum -y install      shadow-utils.x86_64 xmlstarlet saxon augeas bsdtar unzip && yum clean all

这应该可以解决您的问题。

您也不需要 epel 存储库,因此您可以根据需要将其全部删除。