curl refuses HTTPS inside a Docker container because of the certificate
curl exits with code 60: the remote server's SSL certificate was deemed not OKShort answer
curl checks the server certificate against a CA store, and a slim image may have none. Check with curl -v what the store is, then fix the matching cause: install the ca-certificates package, add your own CA file and run update-ca-certificates, or correct a CURL_CA_BUNDLE path. Do not use -k as a fix.
Fix it fast
1Find out which cause you have
Run curl verbosely inside the container. It shows which CA file or folder it uses and where the check stops.
docker exec -it app curl -v https://example.com docker exec app env | grep -E 'CURL_CA_BUNDLE|SSL_CERT'2Match what you see, then jump to its fix
- 1
Every HTTPS site fails, and the verbose output shows no usable CA fileThe image has no CA store installedFix - 2
Public sites work, but an internal host, a self-signed server or a TLS-inspecting proxy failsOnly your own server or company proxy fails: its CA is not trustedFix - 3
curl exits with code 77, or fails even though ca-certificates is installedCURL_CA_BUNDLE points at a file that is missing or unreadableFix
- 1
What does the error look like?
curl exits with code 60: the remote server's SSL certificate was deemed not OKcurl exits with code 77: problem reading the CA certificate filethe same URL works on the host but fails inside the container
Cause 1 of 3
The image has no CA store installed
1Check
curl's own guide lists 'no CA store installed' as a reason verification fails. On Debian the store comes from the ca-certificates package, which holds the Mozilla CA list.
docker exec app dpkg -s ca-certificates
docker exec app ls /etc/ssl/certs/ca-certificates.crt2Fix
Install the package in the Dockerfile, in the same layer as the other apt step.
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*3Verify
Rebuild and call a public HTTPS URL.
docker build -t app .
docker run --rm app curl https://example.comConfirmed by curl.se
Cause 2 of 3
Only your own server or company proxy fails: its CA is not trusted
1Check
The certificate is signed by a CA that is not in the container's store. curl's guide names a self-signed certificate and a CA missing from the store as reasons for failure.
docker exec app curl -v https://internal.example.com 2>&1 | grep -i -E 'issuer|verif'2Fix
Add the CA certificate (PEM, .crt extension) to the image and rebuild the store. For one-off transfers, --cacert with that file does the same job for a single request.
COPY my-root-ca.crt /usr/local/share/ca-certificates/my-root-ca.crt
RUN update-ca-certificates3Verify
The internal URL now answers without any extra flag.
docker run --rm app curl https://internal.example.comConfirmed by manpages.debian.org
Cause 3 of 3
CURL_CA_BUNDLE points at a file that is missing or unreadable
1Check
curl reads CURL_CA_BUNDLE when it is set and uses it in place of its default. Code 77 means the CA file could not be read: check the path and access rights.
docker exec app printenv CURL_CA_BUNDLE
docker exec app ls -l "$(docker exec app printenv CURL_CA_BUNDLE)"2Fix
Point the variable at a real PEM file that the container user can read, or remove the variable so curl uses its default store.
# Dockerfile
ENV CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt3Verify
Repeat the failing request.
docker run --rm app curl https://example.comConfirmed by curl.se
How do I stop it coming back?
- Install ca-certificates in every slim or minimal base image that makes HTTPS calls.
- Keep company CA files in the repo and add them in the Dockerfile, never with -k in scripts.
- Set CURL_CA_BUNDLE only when you must, and test the path in the build.
- Run one HTTPS request as a build or CI smoke test.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix