-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
Right now, you can do:
dimage = docker.image("whatever/whatever:99")
This seems fine, until you try to spin up a container, where it throws an exception (that you can catch, which is great).
dimage.withRun() { /* do nothing; just attempt to spin up container */ }
The problem is that takes some time on a loaded server, because it spins up a container for no real reason.
I would like a "validate" method. If that verb is too "heavy" and implies too much, "exists" would be fine, e.g.:
dimage = docker.image("whatever/whatever:99") if (dimage.exists()) { ... }
Workaround:
image_id = sh (script: "docker images -q whatever/whatever:99", returnStdout: true).trim() if (image_id.isEmpty()) throw new Exception("Image not found")