diff options
author | Joffrey F <joffrey@docker.com> | 2018-11-27 17:09:36 -0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-11-27 18:58:55 -0800 |
commit | 61bb1ea4849a4d7d2b98a6689d5e1813b06639bd (patch) | |
tree | f5f2adb957574c577bbfb015e22c7f45bdb9167e /compose/container.py | |
parent | eedbb28d5e577eb25595241592ea7b7bb97c902c (diff) |
Don't append slugs to containers created by "up"
This change reverts the new naming convention introduced in 1.23 for service containers.
One-off containers will now use a slug instead of a sequential number as they do not
present addressability concerns and benefit from being capable of running in parallel.
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'compose/container.py')
-rw-r--r-- | compose/container.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compose/container.py b/compose/container.py index 02630686..8a2fb240 100644 --- a/compose/container.py +++ b/compose/container.py @@ -7,6 +7,7 @@ import six from docker.errors import ImageNotFound from .const import LABEL_CONTAINER_NUMBER +from .const import LABEL_ONE_OFF from .const import LABEL_PROJECT from .const import LABEL_SERVICE from .const import LABEL_SLUG @@ -82,12 +83,16 @@ class Container(object): @property def name_without_project(self): if self.name.startswith('{0}_{1}'.format(self.project, self.service)): - return '{0}_{1}{2}'.format(self.service, self.number, '_' + self.slug if self.slug else '') + return '{0}_{1}'.format(self.service, self.number if self.number is not None else self.slug) else: return self.name @property def number(self): + if self.one_off: + # One-off containers are no longer assigned numbers and use slugs instead. + return None + number = self.labels.get(LABEL_CONTAINER_NUMBER) if not number: raise ValueError("Container {0} does not have a {1} label".format( @@ -105,6 +110,10 @@ class Container(object): return self.labels.get(LABEL_SLUG) @property + def one_off(self): + return self.labels.get(LABEL_ONE_OFF) == 'True' + + @property def ports(self): self.inspect_if_not_inspected() return self.get('NetworkSettings.Ports') or {} |