mirror of https://github.com/docker/compose.git
Add --resolve-image-digests argument to config command
Add a --resolve-image-digests argument to the config command that pins images to a specific image digest, just like the bundle command. This can be used to pin images in compose files being used to deploy stacks in Docker 1.13. Signed-off-by: King Chung Huang <kinghuang@mac.com>
This commit is contained in:
parent
1a7e01c39a
commit
1da3ac4715
|
@ -313,13 +313,56 @@ class TopLevelCommand(object):
|
||||||
Usage: config [options]
|
Usage: config [options]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-q, --quiet Only validate the configuration, don't print
|
--resolve-image-digests Pin image tags to digests.
|
||||||
anything.
|
-q, --quiet Only validate the configuration, don't print
|
||||||
--services Print the service names, one per line.
|
anything.
|
||||||
--volumes Print the volume names, one per line.
|
--services Print the service names, one per line.
|
||||||
|
--volumes Print the volume names, one per line.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
compose_config = get_config_from_options(self.project_dir, config_options)
|
compose_config = get_config_from_options(self.project_dir, config_options)
|
||||||
|
image_digests = None
|
||||||
|
|
||||||
|
if options['--resolve-image-digests']:
|
||||||
|
self.project = project_from_options('.', config_options)
|
||||||
|
|
||||||
|
with errors.handle_connection_errors(self.project.client):
|
||||||
|
try:
|
||||||
|
image_digests = get_image_digests(
|
||||||
|
self.project,
|
||||||
|
allow_push=False
|
||||||
|
)
|
||||||
|
except MissingDigests as e:
|
||||||
|
def list_images(images):
|
||||||
|
return "\n".join(" {}".format(name) for name in sorted(images))
|
||||||
|
|
||||||
|
paras = ["Some images are missing digests."]
|
||||||
|
|
||||||
|
if e.needs_push:
|
||||||
|
command_hint = (
|
||||||
|
"Use `docker-compose push {}` to push them. "
|
||||||
|
.format(" ".join(sorted(e.needs_push)))
|
||||||
|
)
|
||||||
|
paras += [
|
||||||
|
"The following images can be pushed:",
|
||||||
|
list_images(e.needs_push),
|
||||||
|
command_hint,
|
||||||
|
]
|
||||||
|
|
||||||
|
if e.needs_pull:
|
||||||
|
command_hint = (
|
||||||
|
"Use `docker-compose pull {}` to pull them. "
|
||||||
|
.format(" ".join(sorted(e.needs_pull)))
|
||||||
|
)
|
||||||
|
|
||||||
|
paras += [
|
||||||
|
"The following images need to be pulled:",
|
||||||
|
list_images(e.needs_pull),
|
||||||
|
command_hint,
|
||||||
|
]
|
||||||
|
|
||||||
|
raise UserError("\n\n".join(paras))
|
||||||
|
|
||||||
if options['--quiet']:
|
if options['--quiet']:
|
||||||
return
|
return
|
||||||
|
@ -332,7 +375,7 @@ class TopLevelCommand(object):
|
||||||
print('\n'.join(volume for volume in compose_config.volumes))
|
print('\n'.join(volume for volume in compose_config.volumes))
|
||||||
return
|
return
|
||||||
|
|
||||||
print(serialize_config(compose_config))
|
print(serialize_config(compose_config, image_digests))
|
||||||
|
|
||||||
def create(self, options):
|
def create(self, options):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue