@@ -19,7 +19,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
19
19
forcerm = False , dockerfile = None , container_limits = None ,
20
20
decode = False , buildargs = None , gzip = False , shmsize = None ,
21
21
labels = None , cache_from = None , target = None , network_mode = None ,
22
- squash = None , extra_hosts = None , platform = None , isolation = None ):
22
+ squash = None , extra_hosts = None , platform = None , isolation = None ,
23
+ use_config_proxy = False ):
23
24
"""
24
25
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
25
26
needs to be set. ``path`` can be a local path (to a directory
@@ -103,6 +104,10 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
103
104
platform (str): Platform in the format ``os[/arch[/variant]]``
104
105
isolation (str): Isolation technology used during build.
105
106
Default: `None`.
107
+ use_config_proxy (bool): If ``True``, and if the docker client
108
+ configuration file (``~/.docker/config.json`` by default)
109
+ contains a proxy configuration, the corresponding environment
110
+ variables will be set in the container being built.
106
111
107
112
Returns:
108
113
A generator for the build output.
@@ -168,9 +173,10 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
168
173
}
169
174
params .update (container_limits )
170
175
171
- proxy_args = self ._proxy_configs .get_environment ()
172
- for k , v in proxy_args .items ():
173
- buildargs .setdefault (k , v )
176
+ if use_config_proxy :
177
+ proxy_args = self ._proxy_configs .get_environment ()
178
+ for k , v in proxy_args .items ():
179
+ buildargs .setdefault (k , v )
174
180
if buildargs :
175
181
params .update ({'buildargs' : json .dumps (buildargs )})
176
182
0 commit comments