I am running Docker through Docker Desktop on a MacOS, and I am having a lot of trouble installing packages in my container because it is being unable to verify any ssl certificates.
When I run apk update
for example, I get this error:
fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
139797308250952:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed:ssl/statem/statem_clnt.c:1914:
ERROR: https://dl-cdn.alpinelinux.org/alpine/v3.14/main: Permission denied
When I try a bundle install
:
Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification.
And even a simple curl curl https://google.com.br
:
curl: (60) SSL certificate problem: unable to get local issuer certificate
More details here: https://curl.se/docs/sslcerts.html
curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.
Update
Even though I installed ca-certificates(as @β.εηοιτ.βε said) inside the container I still get the same error SSL certificate problem: unable to get local issuer certificate
.
Added to the Dockerfile this line, as mentioned by @β.εηοιτ.βε:
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/v3.15/main ca-certificates curl
docker image build
or are you running the commands from a shell within an existing container? – Springycurl: (60)
error (e.g. curling a recently (sometime in 2022) updated tarball as part of a build based on Ubuntu 16.04). Would you mind editing your post to include the Dockerfile or at least the portion leading up to when this error arises, so that folks know the age of the ca-certificates? – SpringyADD ./ZscalerRootCertificate.crt /usr/local/share/ca-certificates/
but in some cases you may need some additional config like for npm/yarn you might need to add the certificate to the npm config, so you will have to run something like this inside the container:npm config set cafile <Path to Certificate>/ca-bundle.pem
– Carlottacarlovingian