Hi have recently started writing Dockerfile From amazonlinux:latest , i can't seem to figure out why groupadd commnd wont work. I have 2 versions , it works in the first one and it doesnt in the 2nd one. The only difference in the 2nd is I added few more packages to be installed in the yum command.
Dockerfile_v1 - this works
FROM amazonlinux:latest
RUN yum install -y shadow-utils.x86_64 && \
yum -y update; yum clean all && \
rm -fr /var/cache/yum
RUN groupadd -g 10001 test
ADD init /opt/init
CMD /opt/init/start.sh
docker build -t test:v1 .
[+] Building 0.7s (9/9) FINISHED
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 259B 0.0s
=> [internal] load metadata for docker.io/library/amazonlinux:latest 0.3s
=> [1/4] FROM docker.io/library/amazonlinux:latest@sha256:85c8f169ab712d0c5f3fc6616b851b9b9ad0f895daf465fa1bcc95185697bf31 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 56B 0.0s
=> CACHED [2/4] RUN yum install -y shadow-utils.x86_64 && yum -y update; yum clean all && rm -fr /var/cache/yum 0.0s
=> [3/4] RUN groupadd -g 10001 test 0.3s
=> [4/4] ADD init /opt/init 0.1s
=> exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:0d3c36470209a665c52cd51285036d99d598ce07ad90815706d0c25ecfef5e54 0.0s
=> => naming to docker.io/library/test:v1
Dockerfile_v2 - this doesnt work - the only addition being added glibc.i686 libstdc++ libstdc++.i686 to yum install
FROM amazonlinux:latest
RUN yum install -y glibc.i686 libstdc++ libstdc++.i686 shadow-utils.x86_64 && \
yum -y update; yum clean all && \
rm -fr /var/cache/yum
RUN groupadd -g 10001 test
ADD init /opt/init
CMD /opt/init/start.sh
docker build -t test:v2 .
[+] Building 0.9s (7/8)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 294B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/amazonlinux:latest 0.6s
=> [1/4] FROM docker.io/library/amazonlinux:latest@sha256:85c8f169ab712d0c5f3fc6616b851b9b9ad0f895daf465fa1bcc95185697bf31 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 56B 0.0s
=> CACHED [2/4] RUN yum install -y glibc.i686 libstdc++ libstdc++.i686 shadow-utils.x86_64 && yum -y update; yum clean all && rm -fr /var/cache/yum 0.0s
=> ERROR [3/4] RUN groupadd -g 10001 test 0.3s
------
> [3/4] RUN groupadd -g 10001 test:
#0 0.268 /bin/sh: line 1: groupadd: command not found
------
Dockerfile:8
--------------------
6 | rm -fr /var/cache/yum
7 |
8 | >>> RUN groupadd -g 10001 test
9 |
10 | ADD init /opt/init
--------------------
ERROR: failed to solve: process "/bin/sh -c groupadd -g 10001 test" did not complete successfully: exit code: 127
This is cut down version of my actual Dockerfile but this shows the issues well. Please let me know what am I missing here?