公司代理背后的ddev
ddev behind corporate proxy
我希望 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
而且我无法正确使用 composer。
我需要一种方法将环境变量 HTTP_PROXY
、HTTPS_PROXY
和 NO_PROXY
传递给容器,我该如何实现?
更新:
好吧,在阅读了一些 docker 文档之后,有一种现有的方法可以正确定义代理...参见 https://docs.docker.com/network/proxy/
通过在主机上创建文件 ~/.docker/config.json
和
{
"proxies":
{
"default":
{
"httpProxy": "http://ip:port",
"httpsProxy": "http://user:password@ip:port,
"noProxy": "*.test.example.com,.example2.com"
}
}
}
然后 ddev restart
docker 将自动设置所需的环境变量,小写和大写。
有了这个,composer
有效,wget
有效。 apt
仍然无法在容器内工作,因为它仍然需要在 /etc/apt/apt.conf.d/20proxyconf
文件中进行代理设置,但它可以在 .ddev/web-build/Dockerfile
中工作,我认为这就足够了:)
我希望 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
而且我无法正确使用 composer。
我需要一种方法将环境变量 HTTP_PROXY
、HTTPS_PROXY
和 NO_PROXY
传递给容器,我该如何实现?
更新:
好吧,在阅读了一些 docker 文档之后,有一种现有的方法可以正确定义代理...参见 https://docs.docker.com/network/proxy/
通过在主机上创建文件 ~/.docker/config.json
和
{
"proxies":
{
"default":
{
"httpProxy": "http://ip:port",
"httpsProxy": "http://user:password@ip:port,
"noProxy": "*.test.example.com,.example2.com"
}
}
}
然后 ddev restart
docker 将自动设置所需的环境变量,小写和大写。
有了这个,composer
有效,wget
有效。 apt
仍然无法在容器内工作,因为它仍然需要在 /etc/apt/apt.conf.d/20proxyconf
文件中进行代理设置,但它可以在 .ddev/web-build/Dockerfile
中工作,我认为这就足够了:)