root@3511c8b519ea:/# apt-get -yqq update
W: The repository 'http://security.ubuntu.com/ubuntu xenial-security Release' does not have a Release file.
W: The repository 'http://archive.ubuntu.com/ubuntu xenial Release' does not have a Release file.
W: The repository 'http://archive.ubuntu.com/ubuntu xenial-updates Release' does not have a Release file.
W: The repository 'http://archive.ubuntu.com/ubuntu xenial-backports Release' does not have a Release file.
E: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/universe/source/Sources Cannot initiate the connection to 6152:80 (0.0.24.8). - connect (22: Invalid argument)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial/universe/source/Sources Cannot initiate the connection to 6152:80 (0.0.24.8). - connect (22: Invalid argument)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/universe/source/Sources Cannot initiate the connection to 6152:80 (0.0.24.8). - connect (22: Invalid argument)
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-backports/main/binary-amd64/Packages Cannot initiate the connection to 6152:80 (0.0.24.8). - connect (22: Invalid argument)
E: Some index files failed to download. They have been ignored, or old ones used instead.
在网上搜索了相关资料后,发现是网络代理设置的问题:
123
root@3511c8b519ea:/# set | grep proxy
http_proxy=docker.for.mac.localhost:6152
https_proxy=docker.for.mac.localhost:6152
docker.for.mac.localhost 是从 17.06 版本开始引入的一个Mac DNS 名称,会被解析成外部主机的IP。6152 是我设置的代理端口。
要想代理能够生效需要增加一个 http 的前缀:
123
root@1e9af09f86a4:/# set | grep proxy
http_proxy=http://docker.for.mac.localhost:6152
https_proxy=http://docker.for.mac.localhost:6152
或者直接设置不需要使用代理:
123
root@1e9af09f86a4:/# set | grep proxy
http_proxy=no_proxy
https_proxy=no_proxy