Shell command not recognizing the variable
I am able to generate the content for the certificate but when I am trying to pass it on to a file in my container location, shell is not recognizing the variable holding the content of certificate
RUN apk add ca-certificates
RUN apk add --no-cache openssl
RUN CERTS = $(echo -n | openssl s_client -connect keycloak.abc.domain.com:443 -showcerts | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p') && \
echo $CERTS >/usr/local/share/ca-certificates/mycert.crt && \
update-ca-certificates
The error says : Step 14/18 : RUN CERT = $(echo -n | openssl s_client -connect keycloakt.abc.domain.com:443 -showcerts | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p') && echo $CERT >/usr/local/share/ca-certificates/mycert.crt && update-ca-certificates
---> Running in 18e319cfa09b
depth=0 C = MX, ST = xx, L = xx, O = xx, OU = xx, CN = *.xx
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=xx C = xx, ST = xx, L = xx, O = xx, OU = xx, CN = *.xx
verify error:num=21:unable to verify the first certificate
verify return:1
DONE
**/bin/sh: CERT: not found**
The command '/bin/sh -c CERT = $(echo -n | openssl s_client -connect
hostname:port -showcerts | sed -ne '/-BEGIN CERTIFICATE-/,/-END
CERTIFICATE-/p') && echo $CERT >/usr/local/share/ca-
certificates/mycert.crt && update-ca-certificates' returned a non-
zero code: 127
I tried "$CERT" > /usr/local/share/ca-certificates/mycert.crt as well. Also I tried copying the certificate from my local
#RUN apk update && apk add ca-certificates && rm -rf /var/cache/apk/*
#COPY ./mycert.crt /usr/local/share/ca-certificates/mycert.crt
But with this I get : COPY failed: stat /var/lib/docker/tmp/docker-builder950940816/mycert.crt: no such file or directory
Is there another way to pass the value here? Can anyone point out what's wrong in either of the approaches?