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

我有我想要构build的下面的Dockerfile。 它基本上只是普通的jboss / wildfly基础镜像,而是用amazonlinux而不是centOS构build的。

生成错误与行“groupadd:命令未find”

在第一次发生这种情况后,我添加了“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仓库,所以如果你愿意的话,你可以把它们一起移除。