← All Articles

x509 error when using HTTPS inside a Docker container

Khash SajadiKhash Sajadi
Mar 19th 15Updated May 15th 15

If you are getting a 'x509: failed to load system roots and no roots provided' error when you run an HTTPS from inside a container, this might help.

This issue can happen if the base image used to build your Docker container does not have the CA certificates. Here is how it can be reproduced:

FROM ubuntu:14.04.1
CMD curl https://www.google.com

Running this container might generate something like this:

x509: failed to load system roots and no roots provided

The reason for this is that the base image (ubuntu:14.04.1 in this case) does not have the root CA certificates installed. The solution is easy enough. Install them as part of your image build:

FROM ubuntu:14.04.1

RUN apt-get update
RUN apt-get install -y ca-certificates

CMD curl https://www.google.com

Try Cloud 66 for Free, No credit card required