Pull latest tag by default

This was changed in Docker recently:

https://github.com/docker/docker/pull/7759

This means we aren't pulling loads of tags when we only use the
latest.

Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This commit is contained in:
Ben Firshman 2014-12-08 16:03:42 -08:00
commit 8ebec9a67f
2 changed files with 39 additions and 6 deletions

View file

@ -381,6 +381,8 @@ class Service(object):
if len(self.client.images(name=self._build_tag_name())) == 0:
self.build()
container_options['image'] = self._build_tag_name()
else:
container_options['image'] = self._get_image_name(container_options['image'])
# Delete options which are only used when starting
for key in ['privileged', 'net', 'dns', 'restart', 'cap_add', 'cap_drop']:
@ -389,6 +391,12 @@ class Service(object):
return container_options
def _get_image_name(self, image):
repo, tag = parse_repository_tag(image)
if tag == "":
tag = "latest"
return '%s:%s' % (repo, tag)
def build(self, no_cache=False):
log.info('Building %s...' % self.name)
@ -435,9 +443,10 @@ class Service(object):
def pull(self, insecure_registry=False):
if 'image' in self.options:
log.info('Pulling %s (%s)...' % (self.name, self.options.get('image')))
image_name = self._get_image_name(self.options['image'])
log.info('Pulling %s (%s)...' % (self.name, image_name))
self.client.pull(
self.options.get('image'),
image_name,
insecure_registry=insecure_registry
)
@ -509,6 +518,15 @@ def parse_volume_spec(volume_config):
return VolumeSpec(external, internal, mode)
def parse_repository_tag(s):
if ":" not in s:
return s, ""
repo, tag = s.rsplit(":", 1)
if "/" in tag:
return s, ""
return repo, tag
def build_volume_binding(volume_spec):
internal = {'bind': volume_spec.internal, 'ro': volume_spec.mode == 'ro'}
external = os.path.expanduser(volume_spec.external)