|
@@ -47,12 +47,10 @@ class Container(object):
|
47
|
47
|
self.image_info = image_info
|
48
|
48
|
"""The image information as returned by `docker inspect`"""
|
49
|
49
|
|
50
|
|
-
|
51
|
50
|
def command_line(self):
|
52
|
51
|
"""Gets the full command-line used to run this container."""
|
53
|
52
|
return ['docker', 'run'] + sorted(self.args) + [self.image] + self.cmd
|
54
|
53
|
|
55
|
|
-
|
56
|
54
|
def add_args_from_list(self, template, selector):
|
57
|
55
|
"""Adds an argument for each item in a list.
|
58
|
56
|
|
|
@@ -64,7 +62,6 @@ class Container(object):
|
64
|
62
|
if target:
|
65
|
63
|
self.args.extend([template % entry for entry in target])
|
66
|
64
|
|
67
|
|
-
|
68
|
65
|
def if_image_diff(self, selector, fallback):
|
69
|
66
|
"""Gets a property if it's different from the image's config.
|
70
|
67
|
|
|
@@ -225,7 +222,11 @@ def modify_labels(parser=None, args=None, container=None):
|
225
|
222
|
parser.add_argument('--label', '-l', action='append',
|
226
|
223
|
help='The new label to add to the container.')
|
227
|
224
|
elif args.label:
|
228
|
|
- container.args.extend(['--label=%s' % label for label in args.label])
|
|
225
|
+ for label in args.label:
|
|
226
|
+ # Remove any existing label with the same key
|
|
227
|
+ prefix = label.split('=')[0]
|
|
228
|
+ container.args = [arg for arg in container.args if not arg.startswith('--label=%s=' % prefix)
|
|
229
|
+ and not arg == '--label=%s' % prefix] + ['--label=%s' % label]
|
229
|
230
|
|
230
|
231
|
|
231
|
232
|
def modify_network(parser=None, args=None, container=None):
|
|
@@ -342,5 +343,6 @@ def entrypoint():
|
342
|
343
|
"""Entrypoint for script use."""
|
343
|
344
|
main(sys.argv[1:], sys.stdout)
|
344
|
345
|
|
|
346
|
+
|
345
|
347
|
if __name__ == "__main__":
|
346
|
348
|
entrypoint()
|