DOCKER_TLS_VERIFY和DOCKER_CERT_PATH变量有什么作用?

时间:2015-07-02 05:31:37

标签: docker boot2docker dockerfile

我是Docker的新手,在Windows 7上使用boot2docker 当我尝试通过spotify maven插件配置Docker构建时,我被要求设置以下env变量:

DOCKER_HOST
DOCKER_CERT_PATH
DOCKER_TLS_VERIFY

配置成功但不确定 DOCKER_TLS_VERIFYDOCKER_CERT_PATH变量有什么作用?

2 个答案:

答案 0 :(得分:3)

作为mentioned in the README

  

默认情况下,boot2docker在启用了TLS的情况下运行docker 。它会自动生成证书并将其存储在VM内的/home/docker/.docker中   VM启动后,boot2docker up命令会将它们复制到主机上的~/.boot2docker/certs,并输出DOCKER_CERT_PATHDOCKER_TLS_VERIFY环境变量的正确值。

eval "$(boot2docker shellinit)" will also set them correctly.
  

出于安全原因,我们强烈建议不要使用未加密的Docker套接字运行Boot2Docker,但如果您有无法轻松切换的工具,可以通过将DOCKER_TLS=no添加到/var/lib/boot2docker/profile文件来禁用它。 / p>

在更加动态的环境中,boot2docker ip可以更改,请参阅issue 944

答案 1 :(得分:0)

请立即查看以下评论​​。我不是Go开发者,但我理解它的用法。 稍后要编辑,因为它太Spartan。

来自https://github.com/docker/docker/blob/3ea762b9f6ba256cf51bd2c35988f0c48bccf0b0/client/client.go

[...]
// Use DOCKER_HOST to set the url to the docker server.
// Use DOCKER_API_VERSION to set the version of the API to reach, leave empty for latest.
// Use DOCKER_CERT_PATH to load the tls certificates from.
// Use DOCKER_TLS_VERIFY to enable or disable TLS verification, off by default.
func NewEnvClient() (*Client, error) {
    var client *http.Client
    if dockerCertPath := os.Getenv("DOCKER_CERT_PATH"); dockerCertPath != "" {
        options := tlsconfig.Options{
            CAFile:             filepath.Join(dockerCertPath, "ca.pem"),
            CertFile:           filepath.Join(dockerCertPath, "cert.pem"),
            KeyFile:            filepath.Join(dockerCertPath, "key.pem"),
            InsecureSkipVerify: os.Getenv("DOCKER_TLS_VERIFY") == "",
[...]