企业代理背后的ddev

时间:2019-06-25 14:38:08

标签: proxy ddev

我希望ddev Web容器使用我的公司代理设置。 否则,当我运行composer diagnose时,我会得到以下结果:

uid_1000@d24b5fb17f37:/var/www/html$ composer diagnose
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: [Composer\Downloader\TransportException] The "http://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out
Checking https connectivity to packagist: [Composer\Downloader\TransportException] The "https://repo.packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection timed out
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com/rate_limit" file could not be downloaded: failed to open stream: Connection timed out
Checking disk free space: OK
Checking pubkeys: 
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: 

  [Composer\Downloader\TransportException]                                                                          
  The "https://getcomposer.org/versions" file could not be downloaded: failed to open stream: Connection timed out  


diagnose

我不能正确使用作曲器。

我需要一种将环境变量HTTP_PROXYHTTPS_PROXYNO_PROXY传递到容器的方法,该如何实现?

1 个答案:

答案 0 :(得分:1)

更新:

好吧,在阅读了一些 docker 文档之后,有一种可以正确定义代理的现有方法...请参阅https://docs.docker.com/network/proxy/

通过在主机上使用{p>创建文件~/.docker/config.json

{
 "proxies":
 {
   "default":
   {
     "httpProxy": "http://ip:port",
     "httpsProxy": "http://user:password@ip:port,
     "noProxy": "*.test.example.com,.example2.com"
   }
 }
}

然后ddev restart码头工人将自动设置所需的ENV变量,小写和大写。

这样,composer有效,wget有效。 apt仍然无法在容器内工作,因为它仍然需要/etc/apt/apt.conf.d/20proxyconf文件中的代理设置,但是它可以从.ddev/web-build/Dockerfile开始工作,我认为就足够了:)