【问题标题】:What does the DOCKER_TLS_VERIFY and DOCKER_CERT_PATH variable do?DOCKER_TLS_VERIFY 和 DOCKER_CERT_PATH 变量有什么作用?
【发布时间】:2015-07-02 05:31:36
【问题描述】:

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

DOCKER_HOST
DOCKER_CERT_PATH
DOCKER_TLS_VERIFY

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

【问题讨论】:

    标签: docker boot2docker dockerfile


    【解决方案1】:

    作为mentioned in the README:

    默认情况下,boot2docker 在启用 TLS 的情况下运行 docker。它会自动生成证书并将其存储在 VM 内的 /home/docker/.docker 中。
    虚拟机启动后,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 文件来禁用它。

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

    【讨论】:

      【解决方案2】:

      现在请检查下面的 cmets。我不是 Go 开发人员,但我了解它的用法。 太斯巴达了,稍后再编辑。

      来自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") == "",
      [...]
      

      【讨论】:

      • 你能说得更具体点吗?怎么能真正从该代码中读取确切的路径?
      猜你喜欢
      • 2019-06-29
      • 2014-10-03
      • 2017-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-27
      • 2015-05-19
      • 2015-03-05
      相关资源
      最近更新 更多