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

2

24

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!

Carhart answered 26/6, 2017 at 14:45 Comment(1)
You may have found this but It's not meant to have what I'd call essentials installed. You will have to build your amazonlinux container to match your needs. You're still probably missing other essential packages forums.aws.amazon.com/thread.jspa?threadID=242790Durrell
P
28

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.

Perdita answered 29/6, 2017 at 20:19 Comment(4)
I installed shadow-utils.x86_64 and the addgroup command is still unavailable, any idea if there are some other dependencies?Spontaneous
It is groupadd and useradd, not addgroup/adduser.Licha
/bin/sh: yum: command not foundTicktock
@Licha no, these are not the same and they function differently. If I need addgroup I don't mean groupaddLunkhead
F
3

In my case it's an issue of the mac M1. When I use the compatibility mode docker build works:

 export DOCKER_DEFAULT_PLATFORM=linux/amd64 
Foucault answered 7/9, 2022 at 15:17 Comment(1)
where do you run this, inside the Dockerfile ?Perfumer

© 2022 - 2024 — McMap. All rights reserved.