docker container when deploying service Go, throw the wrong file a request https

Error message:

Get https://res.ddkt365.com/ddktRes/imageRes/wx_headimg/0f1d9e55913c22bcaf7cca9b38048d29.jpeg: x509: certificate signed by unknown authority -> http.Get
panic: runtime error: invalid memory address or nil pointer dereference

 

 

 

CA certificate is a problem, the solution is to copy the certificate alpine in the mirror

 

Attach dockerfile Code

# Base image is busybox docker warehouse of 
the FROM Alpine AS certs 
RUN APK APK Update && the Add CA-Certificates 
# mirror copy certificates from other 
the FROM busybox 
COPY the --from = certs / etc / ssl / certs / etc / ssl / certs 
# On the signature 
LABEL author = "[email protected]" 
# working directory 
WORKDIR / root 

# Add files 
the ADD ./bin/ddkt-poster-go ./ddkt-poster-go 
the ADD ./bin/conf.toml ./conf. toml 
the ADD ./fonts ./fonts 
# expose the port number 
#EXPOSE 8080 
password when performing the operation of container # 
EntryPoint [ "./ddkt-poster-go", "-conf", "conf.toml"]

  

 

 

 

liugx@MacBook-Pro  ~/work/personal/golang/ddkt-poster   liugx_code_youhua ●  docker build -t ddkt-poster-go .
Sending build context to Docker daemon  78.08MB
Step 1/10 : FROM alpine as certs
latest: Pulling from library/alpine
aad63a933944: Pull complete 
Digest: sha256:b276d875eeed9c7d3f1cfa7edb06b22ed22b14219a7d67c52c56612330348239
Status: Downloaded newer image for alpine:latest
 ---> a187dde48cd2
Step 2/10 : RUN apk update && apk add ca-certificates
 ---> Running in 1a290f0b3176
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.5-5-gfa48ebadee [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.5-1-ge59ae1cbad [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11265 distinct packages available
(1/1) Installing ca-certificates (20191127-r1)
Executing busybox-1.31.1-r9.trigger
Executing ca-certificates-20191127-r1.trigger
OK: 6 MiB in 15 packages
Removing intermediate container 1a290f0b3176
 ---> 409d89df1e27
Step 3/10 : FROM busybox
 ---> 83aa35aa1c79
Step 4/10 : COPY --from=certs /etc/ssl/certs /etc/ssl/certs
 ---> f3d288b6f60c
Step 5/10 : LABEL author="[email protected]"
 ---> Running in 81fa23a198e9
Removing intermediate container 81fa23a198e9
 ---> 474ca6db3d19
Step 6/10 : WORKDIR /root
 ---> Running in 670487d3f2a5
Removing intermediate container 670487d3f2a5
 ---> ebbc723821b0
Step 7/10 : ADD ./bin/ddkt-poster-go ./ddkt-poster-go
 ---> 89d7a0e23eca
Step 8/10 : ADD ./bin/conf.toml ./conf.toml
 ---> 4ba50a3e49f8
Step 9/10 : ADD ./fonts ./fonts
 ---> 672cb62f608a
Step 10/10 : ENTRYPOINT ["./ddkt-poster-go", "-conf", "conf.toml"]
 ---> Running in 86afb270dab0
Removing intermediate container 86afb270dab0
 ---> da2ec7a93580
Successfully built da2ec7a93580
Successfully tagged ddkt-poster-go:latest
 liugx@MacBook-Pro  ~/work/personal/golang/ddkt-poster   liugx_code_youhua ●  
Implementation process

 

Reference links:

https://stackoverflow.com/questions/45388934/how-do-i-make-an-https-call-in-a-busybox-docker-container-running-go

 

Guess you like

Origin www.cnblogs.com/liugx/p/12578077.html