Class: DockerEngineAPI::Resources::Images
- Inherits:
-
Object
- Object
- DockerEngineAPI::Resources::Images
- Defined in:
- lib/docker_engine_api/resources/images.rb
Instance Method Summary collapse
-
#build(body:, buildargs: nil, cachefrom: nil, cpuperiod: nil, cpuquota: nil, cpusetcpus: nil, cpushares: nil, dockerfile: nil, extrahosts: nil, forcerm: nil, labels: nil, memory: nil, memswap: nil, networkmode: nil, nocache: nil, outputs: nil, platform: nil, pull: nil, q: nil, remote: nil, rm: nil, shmsize: nil, squash: nil, t: nil, target: nil, version: nil, x_registry_config: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ImageBuildParams for more details.
-
#build_prune(all: nil, filters: nil, max_used_space: nil, min_free_space: nil, reserved_space: nil, request_options: {}) ⇒ DockerEngineAPI::Models::ImageBuildPruneResponse
Some parameter documentations has been truncated, see Models::ImageBuildPruneParams for more details.
-
#commit(author: nil, changes: nil, comment: nil, container: nil, pause: nil, repo: nil, tag: nil, args_escaped: nil, attach_stderr: nil, attach_stdin: nil, attach_stdout: nil, cmd: nil, domainname: nil, entrypoint: nil, env: nil, exposed_ports: nil, healthcheck: nil, hostname: nil, image: nil, labels: nil, network_disabled: nil, on_build: nil, open_stdin: nil, shell: nil, stdin_once: nil, stop_signal: nil, stop_timeout: nil, tty: nil, user: nil, volumes: nil, working_dir: nil, request_options: {}) ⇒ DockerEngineAPI::Models::ImageCommitResponse
Some parameter documentations has been truncated, see Models::ImageCommitParams for more details.
-
#delete(name, force: nil, noprune: nil, platforms: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::DeleteItem>
Some parameter documentations has been truncated, see Models::ImageDeleteParams for more details.
-
#get(name, platform: nil, request_options: {}) ⇒ StringIO
Some parameter documentations has been truncated, see Models::ImageGetParams for more details.
-
#get_all(names: nil, platform: nil, request_options: {}) ⇒ StringIO
Some parameter documentations has been truncated, see Models::ImageGetAllParams for more details.
-
#history(name, platform: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::HistoryItem>
Some parameter documentations has been truncated, see Models::ImageHistoryParams for more details.
-
#initialize(client:) ⇒ Images
constructor
private
A new instance of Images.
-
#inspect_(name, manifests: nil, request_options: {}) ⇒ DockerEngineAPI::Models::Image
Return low-level information about an image.
-
#list(all: nil, digests: nil, filters: nil, manifests: nil, shared_size: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::Summary>
Some parameter documentations has been truncated, see Models::ImageListParams for more details.
-
#load_(body:, platform: nil, quiet: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ImageLoadParams for more details.
-
#prune(filters: nil, request_options: {}) ⇒ DockerEngineAPI::Models::ImagePruneResponse
Some parameter documentations has been truncated, see Models::ImagePruneParams for more details.
-
#pull(changes: nil, from_image: nil, from_src: nil, message: nil, platform: nil, repo: nil, tag: nil, body: nil, x_registry_auth: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ImagePullParams for more details.
-
#push(name, x_registry_auth:, platform: nil, tag: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ImagePushParams for more details.
-
#search(term:, filters: nil, limit: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::ImageSearchResponseItem>
Some parameter documentations has been truncated, see Models::ImageSearchParams for more details.
-
#tag(name, repo: nil, tag: nil, request_options: {}) ⇒ nil
Create a tag that refers to a source image.
Constructor Details
#initialize(client:) ⇒ Images
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Images.
671 672 673 |
# File 'lib/docker_engine_api/resources/images.rb', line 671 def initialize(client:) @client = client end |
Instance Method Details
#build(body:, buildargs: nil, cachefrom: nil, cpuperiod: nil, cpuquota: nil, cpusetcpus: nil, cpushares: nil, dockerfile: nil, extrahosts: nil, forcerm: nil, labels: nil, memory: nil, memswap: nil, networkmode: nil, nocache: nil, outputs: nil, platform: nil, pull: nil, q: nil, remote: nil, rm: nil, shmsize: nil, squash: nil, t: nil, target: nil, version: nil, x_registry_config: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ImageBuildParams for more details.
Build an image from a tar archive with a Dockerfile in it.
The Dockerfile specifies how the image is built from the tar archive. It is typically in the archive’s root, but can be at a different path or have a different name by specifying the dockerfile parameter. [See the Dockerfile reference for more information](docs.docker.com/engine/reference/builder/).
The Docker daemon performs a preliminary validation of the Dockerfile before starting the build, and returns an error if the syntax is incorrect. After that, each instruction is run one-by-one until the ID of the new image is output.
The build is canceled if the client drops the connection by quitting or being killed.
*(Experimen
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/docker_engine_api/resources/images.rb', line 154 def build(params) parsed, = DockerEngineAPI::ImageBuildParams.dump_request(params) query_params = [ :buildargs, :cachefrom, :cpuperiod, :cpuquota, :cpusetcpus, :cpushares, :dockerfile, :extrahosts, :forcerm, :labels, :memory, :memswap, :networkmode, :nocache, :outputs, :platform, :pull, :q, :remote, :rm, :shmsize, :squash, :t, :target, :version ] @client.request( method: :post, path: "build", query: parsed.slice(*query_params), headers: { "content-type" => "application/octet-stream", **parsed.except(:body, *query_params) }.transform_keys( x_registry_config: "x-registry-config" ), body: parsed[:body], model: NilClass, options: ) end |
#build_prune(all: nil, filters: nil, max_used_space: nil, min_free_space: nil, reserved_space: nil, request_options: {}) ⇒ DockerEngineAPI::Models::ImageBuildPruneResponse
Some parameter documentations has been truncated, see Models::ImageBuildPruneParams for more details.
Delete builder cache
222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/docker_engine_api/resources/images.rb', line 222 def build_prune(params = {}) parsed, = DockerEngineAPI::ImageBuildPruneParams.dump_request(params) @client.request( method: :post, path: "build/prune", query: parsed.transform_keys( max_used_space: "max-used-space", min_free_space: "min-free-space", reserved_space: "reserved-space" ), model: DockerEngineAPI::Models::ImageBuildPruneResponse, options: ) end |
#commit(author: nil, changes: nil, comment: nil, container: nil, pause: nil, repo: nil, tag: nil, args_escaped: nil, attach_stderr: nil, attach_stdin: nil, attach_stdout: nil, cmd: nil, domainname: nil, entrypoint: nil, env: nil, exposed_ports: nil, healthcheck: nil, hostname: nil, image: nil, labels: nil, network_disabled: nil, on_build: nil, open_stdin: nil, shell: nil, stdin_once: nil, stop_signal: nil, stop_timeout: nil, tty: nil, user: nil, volumes: nil, working_dir: nil, request_options: {}) ⇒ DockerEngineAPI::Models::ImageCommitResponse
Some parameter documentations has been truncated, see Models::ImageCommitParams for more details.
Create a new image from a container
311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/docker_engine_api/resources/images.rb', line 311 def commit(params = {}) parsed, = DockerEngineAPI::ImageCommitParams.dump_request(params) query_params = [:author, :changes, :comment, :container, :pause, :repo, :tag] @client.request( method: :post, path: "commit", query: parsed.slice(*query_params), body: parsed.except(*query_params), model: DockerEngineAPI::Models::ImageCommitResponse, options: ) end |
#delete(name, force: nil, noprune: nil, platforms: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::DeleteItem>
Some parameter documentations has been truncated, see Models::ImageDeleteParams for more details.
Remove an image, along with any untagged parent images that were referenced by that image.
Images can’t be removed if they have descendant images, are being used by a running container or are being used by a build.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/docker_engine_api/resources/images.rb', line 64 def delete(name, params = {}) parsed, = DockerEngineAPI::ImageDeleteParams.dump_request(params) @client.request( method: :delete, path: ["images/%1$s", name], query: parsed, model: DockerEngineAPI::Internal::Type::ArrayOf[DockerEngineAPI::DeleteItem], options: ) end |
#get(name, platform: nil, request_options: {}) ⇒ StringIO
Some parameter documentations has been truncated, see Models::ImageGetParams for more details.
Get a tarball containing all images and metadata for a repository.
If name is a specific name and tag (e.g. ubuntu:latest), then only that image (and its parents) are returned. If name is an image ID, similarly only that image (and its parents) are returned, but with the exclusion of the repositories file in the tarball, as there were no image names referenced.
### Image tarball format
An image tarball contains [Content as defined in the OCI Image Layout Specification](github.com/opencontainers/image-spec/blob/v1.1.1/image-layout.md#content).
Additionally, includes the manifest.json file associated with a backwards compatible docker save format.
If the tarball defines a repository, the tarball should also include a repositories file at the root that contains a list of repository and tag names mapped to layer IDs.
“‘json {
"hello-world": {
"latest": "565a9d68a73f6706862bfe8409a7f659776d4d60a8d096eb4a3cbce6999cc2a1"
}
} “‘
365 366 367 368 369 370 371 372 373 374 375 |
# File 'lib/docker_engine_api/resources/images.rb', line 365 def get(name, params = {}) parsed, = DockerEngineAPI::ImageGetParams.dump_request(params) @client.request( method: :get, path: ["images/%1$s/get", name], query: parsed, headers: {"accept" => "application/x-tar"}, model: StringIO, options: ) end |
#get_all(names: nil, platform: nil, request_options: {}) ⇒ StringIO
Some parameter documentations has been truncated, see Models::ImageGetAllParams for more details.
Get a tarball containing all images and metadata for several image repositories.
For each value of the names parameter: if it is a specific name and tag (e.g. ubuntu:latest), then only that image (and its parents) are returned; if it is an image ID, similarly only that image (and its parents) are returned and there would be no names referenced in the ‘repositories’ file for this image ID.
For details on the format, see the [export image endpoint](#operation/ImageGet).
400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/docker_engine_api/resources/images.rb', line 400 def get_all(params = {}) parsed, = DockerEngineAPI::ImageGetAllParams.dump_request(params) @client.request( method: :get, path: "images/get", query: parsed, headers: {"accept" => "application/x-tar"}, model: StringIO, options: ) end |
#history(name, platform: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::HistoryItem>
Some parameter documentations has been truncated, see Models::ImageHistoryParams for more details.
Return parent layers of an image.
428 429 430 431 432 433 434 435 436 437 |
# File 'lib/docker_engine_api/resources/images.rb', line 428 def history(name, params = {}) parsed, = DockerEngineAPI::ImageHistoryParams.dump_request(params) @client.request( method: :get, path: ["images/%1$s/history", name], query: parsed, model: DockerEngineAPI::Internal::Type::ArrayOf[DockerEngineAPI::HistoryItem], options: ) end |
#inspect_(name, manifests: nil, request_options: {}) ⇒ DockerEngineAPI::Models::Image
Return low-level information about an image.
452 453 454 455 456 457 458 459 460 461 |
# File 'lib/docker_engine_api/resources/images.rb', line 452 def inspect_(name, params = {}) parsed, = DockerEngineAPI::ImageInspectParams.dump_request(params) @client.request( method: :get, path: ["images/%1$s/json", name], query: parsed, model: DockerEngineAPI::Image, options: ) end |
#list(all: nil, digests: nil, filters: nil, manifests: nil, shared_size: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::Summary>
Some parameter documentations has been truncated, see Models::ImageListParams for more details.
Returns a list of images on the server. Note that it uses a different, smaller representation of an image than inspecting a single image.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/docker_engine_api/resources/images.rb', line 29 def list(params = {}) parsed, = DockerEngineAPI::ImageListParams.dump_request(params) @client.request( method: :get, path: "images/json", query: parsed.transform_keys(shared_size: "shared-size"), model: DockerEngineAPI::Internal::Type::ArrayOf[DockerEngineAPI::Summary], options: ) end |
#load_(body:, platform: nil, quiet: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ImageLoadParams for more details.
Load a set of images and tags into a repository.
For details on the format, see the [export image endpoint](#operation/ImageGet).
483 484 485 486 487 488 489 490 491 492 493 494 |
# File 'lib/docker_engine_api/resources/images.rb', line 483 def load_(params) parsed, = DockerEngineAPI::ImageLoadParams.dump_request(params) @client.request( method: :post, path: "images/load", query: parsed.except(:body), headers: {"content-type" => "application/x-tar"}, body: parsed[:body], model: NilClass, options: ) end |
#prune(filters: nil, request_options: {}) ⇒ DockerEngineAPI::Models::ImagePruneResponse
Some parameter documentations has been truncated, see Models::ImagePruneParams for more details.
Delete unused images
510 511 512 513 514 515 516 517 518 519 |
# File 'lib/docker_engine_api/resources/images.rb', line 510 def prune(params = {}) parsed, = DockerEngineAPI::ImagePruneParams.dump_request(params) @client.request( method: :post, path: "images/prune", query: parsed, model: DockerEngineAPI::Models::ImagePruneResponse, options: ) end |
#pull(changes: nil, from_image: nil, from_src: nil, message: nil, platform: nil, repo: nil, tag: nil, body: nil, x_registry_auth: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ImagePullParams for more details.
Pull or import an image.
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 |
# File 'lib/docker_engine_api/resources/images.rb', line 551 def pull(params = {}) parsed, = DockerEngineAPI::ImagePullParams.dump_request(params) query_params = [:changes, :from_image, :from_src, :message, :platform, :repo, :tag] @client.request( method: :post, path: "images/create", query: parsed.slice(*query_params).transform_keys(from_image: "fromImage", from_src: "fromSrc"), headers: { "content-type" => "application/octet-stream", **parsed.except(:body, *query_params) }.transform_keys( x_registry_auth: "x-registry-auth" ), body: parsed[:body], model: NilClass, options: ) end |
#push(name, x_registry_auth:, platform: nil, tag: nil, request_options: {}) ⇒ nil
Some parameter documentations has been truncated, see Models::ImagePushParams for more details.
Push an image to a registry.
If you wish to push an image on to a private registry, that image must already have a tag which references the registry. For example, registry.example.com/myimage:latest.
The push is cancelled if the HTTP connection is closed.
596 597 598 599 600 601 602 603 604 605 606 607 |
# File 'lib/docker_engine_api/resources/images.rb', line 596 def push(name, params) parsed, = DockerEngineAPI::ImagePushParams.dump_request(params) query_params = [:platform, :tag] @client.request( method: :post, path: ["images/%1$s/push", name], query: parsed.slice(*query_params), headers: parsed.except(*query_params).transform_keys(x_registry_auth: "x-registry-auth"), model: NilClass, options: ) end |
#search(term:, filters: nil, limit: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::ImageSearchResponseItem>
Some parameter documentations has been truncated, see Models::ImageSearchParams for more details.
Search for an image on Docker Hub.
627 628 629 630 631 632 633 634 635 636 |
# File 'lib/docker_engine_api/resources/images.rb', line 627 def search(params) parsed, = DockerEngineAPI::ImageSearchParams.dump_request(params) @client.request( method: :get, path: "images/search", query: parsed, model: DockerEngineAPI::Internal::Type::ArrayOf[DockerEngineAPI::Models::ImageSearchResponseItem], options: ) end |
#tag(name, repo: nil, tag: nil, request_options: {}) ⇒ nil
Create a tag that refers to a source image.
This creates an additional reference (tag) to the source image. The tag can include a different repository name and/or tag. If the repository or tag already exists, it will be overwritten.
657 658 659 660 661 662 663 664 665 666 |
# File 'lib/docker_engine_api/resources/images.rb', line 657 def tag(name, params = {}) parsed, = DockerEngineAPI::ImageTagParams.dump_request(params) @client.request( method: :post, path: ["images/%1$s/tag", name], query: parsed, model: NilClass, options: ) end |