We are doing ...
ENV http_proxy http://9.9.9.9:9999
ENV https_proxy http://9.9.9.9:9999
and at end of dockerfile ...
ENV http_proxy ""
ENV https_proxy ""
This, for now (until docker introduces build env vars), allows the proxy env vars to be used for the build ONLY without exposing them
The alternative to solution is NOT to build your images locally behind a proxy but to let docker build your images for you using docker "automated builds". Since docker is not building the images behind your proxy the problem is solved. An example of an automated build is available at ...
https://github.com/danday74/docker-nginx-lua (GITHUB repo)
https://registry.hub.docker.com/u/danday74/nginx-lua (DOCKER repo which is watching the github repo using an automated build and doing a docker build on a push to the github master branch)