Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have the below Dockerfile which I want to build. It's basically just the normal jboss/wildfly base image, but built with amazonlinux instead of centOS.

The build error's out with the line "groupadd: Command not found"

After this happened the first time I added the "epel" repo and tried installing it manually as you can see in the first RUN instruction. I have read a few forums and seems like sometimes you get that error message when you're not running as root. I did a "whoami" and I am running as root, so it shouldn't be an issue.

Anyone got any idea why I'm still getting an error?

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

Thanks in advance!

like image 761
Sollie Avatar asked Jun 26 '17 14:06

Sollie


1 Answers

Your problem is that groupadd is not a package, so you can't install it like you are attempting to do at the moment.

You can install shadow-utils.x86_64, which will make the groupadd command available.

yum install shadow-utils.x86_64 -y

Or to modify your "RUN" line:

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

That should fix your issue.

You also don't need the epel repository, so you can remove that bit all together if you want.

like image 157
sj.meyer Avatar answered Sep 18 '22 19:09

sj.meyer