Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 56
Images API
finalDockerdocker = ...;
finalImagesimages = docker.images();- Pull an Image
- Import an Image
- Iterate Over Images
- Work With An Image
- Import Images from Tar File
- Delete (prune) Unused Images
- Filter Images
- Get Parent Docker
This will pull an image, from the Registry, to the Docker Engine.
finalImagehelloWorld = images.pull("hello-world", "latest");This will import an Image, from the given URL and Repo, to the Docker Engine
finalImageimported = images.import(
newURL("http://example.com/exampleimage.tgz"),
"hello-world"
);Images implements Iterable<Image>. To iterate over all images in the Docke Engine (no filters applied), just use:
for(finalImageimg : images) {
//...
}An Image represents the Image JSON resource in Docker as well as the API endpoints performing on this resource. Image implements javax.json.JsonObject and holds the JSON representation accurate at the moment of its instantiation.
Once you have an Image, here's what you can do with it:
finalImageimage = ...;
finalContainerrunning = image.run(); //run a Container from it.finalJsonObjectinspection = image.inspect(); //get the latest JSON inspectionfinalIterable<Image> history = image.history(); //get its Historyimage.tag("repo", "name"); //tag the Imageimage.delete(); //delete it
...This call will upload the read images to the Docker engine and return all of them (pre-existing and imported) back.
finalImagesfromTar = images.importFromTar("/path/images.tar");This call will delete all the unused images from the Docker Engine.
images.prune();You can filter them by providing a Map of filters as explained in the API Guide:
finalImagesfiltered = images.filter(...);Get the Docker instance to which the Images belong:
finalDockerparent = images.docker();