Merge pull request #716 from bfirsh/pull-latest-tag-by-default
Pull latest tag by default
This commit is contained in:
commit
64762c9dea
2 changed files with 39 additions and 6 deletions
|
|
@ -403,6 +403,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', 'env_file']:
|
||||
|
|
@ -411,6 +413,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)
|
||||
|
||||
|
|
@ -457,9 +465,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
|
||||
)
|
||||
|
||||
|
|
@ -531,6 +540,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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue