certificate error with Go HTTP client in alpine Docker

Using the Go HTTP client from a alpine docker image will result in this error – x509: failed to load system roots and no roots provided

Solution: alpine is a minimal image, hence CA certificates are required. You add that in the Dockerfile as per below example

FROM alpine 
RUN apk add --no-cache ca-certificates 
COPY my-app .
CMD ["./my-app"]

Got this hint from the golang alpine Dockerfile
Cheers!

About Abhishek

Loves Go, NoSQL DBs and messaging systems
This entry was posted in go and tagged , , , . Bookmark the permalink.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.