Fix #3281: Unexpected result when using build args with default values
Fix the issue when build arg is set to None instead of empty string. Usecase: cat docker-compose.yml .... args: - http_proxy - https_proxy - no_proxy If http_proxy, https_proxy, no_proxy environment variables are not defined then http_proxy, https_proxy, no_proxy build args will be set to string None which breaks all downloads With this change undefined build args will be set to empty string instead of string None Signed-off-by: Andrey Devyatkin <andrey.a.devyatkin@gmail.com>
This commit is contained in:
parent
e3e8a619cc
commit
c148849f0e
4 changed files with 5 additions and 37 deletions
|
|
@ -701,12 +701,6 @@ class Service(object):
|
|||
|
||||
build_opts = self.options.get('build', {})
|
||||
path = build_opts.get('context')
|
||||
# If build argument is not defined and there is no environment variable
|
||||
# with the same name then build argument value will be None
|
||||
# Moreover it will be sent to the docker engine as None and then
|
||||
# interpreted as string None which in many cases will fail the build
|
||||
# That is why we filter out all pairs with value equal to None
|
||||
buildargs = {k: v for k, v in build_opts.get('args', {}).items() if v != 'None'}
|
||||
# python2 os.path() doesn't support unicode, so we need to encode it to
|
||||
# a byte string
|
||||
if not six.PY3:
|
||||
|
|
@ -721,7 +715,7 @@ class Service(object):
|
|||
pull=pull,
|
||||
nocache=no_cache,
|
||||
dockerfile=build_opts.get('dockerfile', None),
|
||||
buildargs=buildargs,
|
||||
buildargs=build_opts.get('args', None),
|
||||
)
|
||||
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -95,4 +95,4 @@ def microseconds_from_time_nano(time_nano):
|
|||
|
||||
|
||||
def build_string_dict(source_dict):
|
||||
return dict((k, str(v)) for k, v in source_dict.items())
|
||||
return dict((k, str(v if v else '')) for k, v in source_dict.items())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue