Command apk add needs its time to return a non zero exit code
Dockerfile
FROM alpine:3.16
WORKDIR /home/test
COPY script.sh /tmp/
RUN chmod +x /tmp/script.sh \
&& /tmp/script.sh \
&& rm -f /tmp/script.sh
script.sh
#!/bin/sh
apk update
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-2.32-r0.apk
apk add glibc-2.32-r0.apk
sleep 1
docker build -t test-image . --no-cache --progress=plain
will succeed.
If however one comments out sleep 1
it will fail.
The error is always there in the docker build
logs
#8 5.418 ERROR: glibc-2.32-r0: trying to overwrite etc/nsswitch.conf owned by alpine-baselayout-data-3.2.0-r23.
#8 5.490 1 error; 15 MiB in 15 packages
#8 DONE 6.6s