Docker Client TLS Configuration: Setting TLSClientConfig with WithTLS
You can use the client.WithTLS option to set the TLSClientConfig. Here's an example code snippet showing how to do this:
import (
"crypto/tls"
"github.com/docker/docker/client"
)
cli, err := client.NewClientWithOpts(
client.FromEnv,
client.WithAPIVersionNegotiation(),
client.WithTLS(&tls.Config{InsecureSkipVerify: false}),
)
if err != nil {
panic(err)
}
In the code above, we use the client.WithTLS option to set the TLSClientConfig to &tls.Config{InsecureSkipVerify: false}. This enables TLS and verifies the server certificate.
原文地址: https://www.cveoy.top/t/topic/fG3l 著作权归作者所有。请勿转载和采集!