Docker download Google's TensorFlow issue

2019-06-03 18:27发布

问题:

Recently Google introduces the TensorFlow (machine learning library) which is not distributed for Windows I searched and find that it is possible to download it via Docker, I installed the docker on windows 8.1 machine and followed this and this to get things work but since I am using a local proxy then I tried to export HTTP_PROXY, HTTPS_PROXY to /var/lib/boot2docker/profile file and now when I run below command

docker pull b.gcr.io/tensorflow/tensorflow

I get

Using default tag: latest Error response from daemon: unable to ping registry endpoint https://b.gcr.io/v0/ v2 ping attempt failed with error: Get https://b.gcr.io/v2/: http: error connecting to proxy https://localhost:8580: dial tcp 127.0.0.1:8580: connection refused v1 ping attempt failed with error: Get https://b.gcr.io/v1/_ping: http: error connecting to proxy https://localhost:8580: dial tcp 127.0.0.1:8580: connection refused

Can someone tell me how to fix this ?

my docker-machine's profile

回答1:

If you are using docker-machine, you shouldn't have to tinker directly with the docker daemon profile.

Use the --engine-env option when creating your VM instance for docker.
See docker-machine create.

Simply define %HOME%/.bashrc (which will be read when you open your bash session, before doing an ssh to your VM)

alias dm=docker-machine
export http_proxy=$HTTP_PROXY
export https_proxy=$HTTPS_PROXY
export NO_PROXY=$NO_PROXY
export no_proxy=$NO_PROXY

alias dmcv='docker-machine create -d virtualbox --engine-env HTTP_PROXY=$http_proxy --engine-env HTTPS_PROXY=$https_proxy --engine-env http_proxy=$http_proxy --engine-env https_proxy=$https_proxy --engine-env NO_PROXY=$no_proxy --engine-env no_proxy=$no_proxy'

alias d=docker
alias dpsa='docker ps -a'
denv() { eval $(docker-machine env "$@"); }
vbmctr() { eval $(VBoxManage controlvm $1 natpf1 "$1-$2-tcp,tcp,,$2,,$2"); eval $(VBoxManage controlvm $1 natpf1 "$1-$2-udp,udp,,$2,,$2"); }

Make sure your htt(s)_proxy are defined with:

http://username:password@proxy-server.com:port

(note that it always starts with http:// even for https_proxy)

Also make sure to define no_proxy:

NO_PROXY=.company,.sock,localhost,127.0.0.1,::1,192.168.99.100,192.168.99.101,192.168.99.102,192.168.99.103,192.168.99.104

(replace .company by your company extension)

From there, you can do a:

dmcv default
denv default
dm ssh default

The key here is the dmcv alias: it will create the VM with a /var/lib/boot2docker/profile already modified for you with proxy.

Note that I always use the upercase and lowercase versions of those proxy variables, in order to be interpreted by different unix commands (like curl, wget, ...) which rely sometime on lowercase, other times on upercase variable names.