【问题标题】:"groupadd: Command not found" in docker container even though I install it and I am rootdocker 容器中的“groupadd:找不到命令”,即使我安装了它并且我是 root
【发布时间】:2017-11-29 10:50:17
【问题描述】:

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

构建错误出现在“groupadd: Command not found”这一行

在我第一次添加“epel”存储库并尝试手动安装它之后,正如您在第一个 RUN 指令中看到的那样。我已经阅读了一些论坛,并且似乎有时您在不以 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

提前致谢!

【问题讨论】:

标签: docker amazon-linux


【解决方案1】:

你的问题是 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 存储库,因此您可以根据需要一起删除该位。

【讨论】:

  • 我安装了shadow-utils.x86_64,addgroup命令还是不可用,不知道还有没有其他依赖?
  • 是groupadd和useradd,不是addgroup/adduser。
猜你喜欢
  • 1970-01-01
  • 2021-07-23
  • 2019-05-09
  • 1970-01-01
  • 1970-01-01
  • 2019-04-14
  • 1970-01-01
  • 1970-01-01
  • 2012-05-16
相关资源
最近更新 更多