十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。
Docker网络代理设置
上一篇 /
下一篇 2018-08-05 15:00:24
/ 个人分类:docker
背景
在一些实验室环境,服务器没有直接连接外网的权限,需要通过网络代理。我们通常会将网络代理直接配置在/etc/environment、/etc/profile之类的配置文件中,这对于大部分操作都是可行的。然而,docker命令却使用不了这些代理。比如docker pull时需要从外网下载镜像,就会出现如下错误: 51Testing软件测试网$f5BFYr
$ docker pull hello-world
Unabletofind image'hello-world:latest' locally
Pulling repository docker.io/library/hello-world
docker: Network timedoutwhiletryingtoconnecttohttps://index.docker.io/v1/repositories/library/hello-world/images. You may wanttocheck your internet connectionorifyou are behind a proxy..
See'dockerrun
ps: 本文在Ubuntu16.04下测试通过。 51Testing软件测试网&ZQaWq?c
k#|
51Testing软件测试网?wv`}T!J0t
解决方案一:
停止docker服务,手动以使用2375端口监听所有网络接口的方式启动docker daemon。 51Testing软件测试网-F#r;U].y5@qS$w5w
$systemctl stop docker.service
51Testing软件测试网3^RQ{o;c9l
$nohup docker daemon -Htcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
51Testing软件测试网Dd:J
f#~Y4^Y
v+te]0X"m0
pd5r.@b9v1Z/bO(l0
详情参见:https://docs.docker.com/v1.11/engine/reference/commandline/daemon/#daemon-socket-option 51Testing软件测试网FiQUH ]M4k2w*el
解决方案二:
编辑配置文件,Ubuntu下是/etc/default/docker,CentOS下是/etc/sysconfig/docker。不过通过修改这两个文件来配置daemon已经是discouraged的了。不鼓励使用这种方法。