11
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

scratchイメージを使用する際にx509: certificate signed by unknown authorityが出る

Last updated at Posted at 2019-09-08

はじめに

goでdocker imageを作る際はgoイメージ上で実行ファイルをビルドし,実行ファイルをscratchなイメージにコピーしてdocker imageを生成しております.
いざ生成したdocker imageを実行する際にタイトルのエラーが出る場合あります.
毎回対処法を忘れてしまうので備忘録として残します

最終的なdockerfile

FROM golang:1.12-alpine as builder

RUN apk update && apk add git make

WORKDIR /app

ENV GO111MODULE=on

COPY go.mod .
COPY go.sum .
RUN go mod download

COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o goapp cmd/root/main.go

# for reduce image size
FROM scratch
COPY --from=builder /app/goapp /app/
####### これが必要 ##############
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/

ENTRYPOINT ["/app/goapp"]
11
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?