Class: DockerEngineRuby::Resources::Images

Inherits:
Object
  • Object
show all
Defined in:
lib/docker_engine_ruby/resources/images.rb

Instance Method Summary collapse

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.

Parameters:



554
555
556
# File 'lib/docker_engine_ruby/resources/images.rb', line 554

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

Build an image

Parameters:

  • body (Pathname, StringIO, IO, String, DockerEngineRuby::FilePart)

    Body param

  • buildargs (String)

    Query param

  • cachefrom (String)

    Query param

  • cpuperiod (Integer)

    Query param

  • cpuquota (Integer)

    Query param

  • cpusetcpus (String)

    Query param

  • cpushares (Integer)

    Query param

  • dockerfile (String)

    Query param

  • extrahosts (String)

    Query param

  • forcerm (Boolean)

    Query param

  • labels (String)

    Query param

  • memory (Integer)

    Query param

  • memswap (Integer)

    Query param

  • networkmode (String)

    Query param

  • nocache (Boolean)

    Query param

  • outputs (String)

    Query param

  • platform (String)

    Query param

  • pull (String)

    Query param

  • q (Boolean)

    Query param

  • remote (String)

    Query param

  • rm (Boolean)

    Query param

  • shmsize (Integer)

    Query param

  • squash (Boolean)

    Query param

  • t (String)

    Query param

  • target (String)

    Query param

  • version (Symbol, DockerEngineRuby::Models::ImageBuildParams::Version)

    Query param

  • x_registry_config (String)

    Header param

  • request_options (DockerEngineRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/docker_engine_ruby/resources/images.rb', line 120

def build(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
    ]
  parsed, options = DockerEngineRuby::ImageBuildParams.dump_request(params)
  @client.request(
    method: :post,
    path: "build",
    query: parsed.slice(*query_params),
    headers: {
      "content-type" => "application/x-tar",
      **parsed.except(:body, *query_params)
    }.transform_keys(
      x_registry_config: "x-registry-config"
    ),
    body: parsed[:body],
    model: NilClass,
    options: options
  )
end

#build_prune(all: nil, filters: nil, max_used_space: nil, min_free_space: nil, reserved_space: nil, request_options: {}) ⇒ DockerEngineRuby::Models::ImageBuildPruneResponse

Delete builder cache

Parameters:

  • all (Boolean)
  • filters (String)
  • max_used_space (Integer)
  • min_free_space (Integer)
  • reserved_space (Integer)
  • request_options (DockerEngineRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/docker_engine_ruby/resources/images.rb', line 180

def build_prune(params = {})
  parsed, options = DockerEngineRuby::ImageBuildPruneParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :post,
    path: "build/prune",
    query: query.transform_keys(
      max_used_space: "max-used-space",
      min_free_space: "min-free-space",
      reserved_space: "reserved-space"
    ),
    model: DockerEngineRuby::Models::ImageBuildPruneResponse,
    options: 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: {}) ⇒ DockerEngineRuby::Models::ImageCommitResponse

Some parameter documentations has been truncated, see Models::ImageCommitParams for more details.

Create a new image from a container

Parameters:

  • author (String)

    Query param

  • changes (String)

    Query param

  • comment (String)

    Query param

  • container (String)

    Query param

  • pause (Boolean)

    Query param

  • repo (String)

    Query param

  • tag (String)

    Query param

  • args_escaped (Boolean, nil)

    Body param: Command is already escaped (Windows only)

  • attach_stderr (Boolean)

    Body param: Whether to attach to ‘stderr`.

  • attach_stdin (Boolean)

    Body param: Whether to attach to ‘stdin`.

  • attach_stdout (Boolean)

    Body param: Whether to attach to ‘stdout`.

  • cmd (Array<String>)

    Body param: Command to run specified as a string or an array of strings.

  • domainname (String)

    Body param: The domain name to use for the container.

  • entrypoint (Array<String>)

    Body param: The entry point for the container as a string or an array of strings

  • env (Array<String>)

    Body param: A list of environment variables to set inside the container in the

  • exposed_ports (Hash{Symbol=>Hash{Symbol=>Object}}, nil)

    Body param: An object mapping ports to an empty object in the form:

  • healthcheck (DockerEngineRuby::Models::Config::Healthcheck)

    Body param: A test to perform to check that the container is healthy.

  • hostname (String)

    Body param: The hostname to use for the container, as a valid RFC 1123 hostname.

  • image (String)

    Body param: The name (or reference) of the image to use when creating the contai

  • labels (Hash{Symbol=>String})

    Body param: User-defined key/value metadata.

  • network_disabled (Boolean, nil)

    Body param: Disable networking for the container.

  • on_build (Array<String>, nil)

    Body param: ‘ONBUILD` metadata that were defined in the image’s ‘Dockerfile`.

  • open_stdin (Boolean)

    Body param: Open ‘stdin`

  • shell (Array<String>, nil)

    Body param: Shell for when ‘RUN`, `CMD`, and `ENTRYPOINT` uses a shell.

  • stdin_once (Boolean)

    Body param: Close ‘stdin` after one attached client disconnects

  • stop_signal (String, nil)

    Body param: Signal to stop a container as a string or unsigned integer.

  • stop_timeout (Integer, nil)

    Body param: Timeout to stop a container in seconds.

  • tty (Boolean)

    Body param: Attach standard streams to a TTY, including ‘stdin` if it is not clo

  • user (String)

    Body param: Commands run as this user inside the container. If omitted, commands

  • volumes (Hash{Symbol=>Hash{Symbol=>Object}})

    Body param: An object mapping mount point paths inside the container to empty

  • working_dir (String)

    Body param: The working directory for commands to run in.

  • request_options (DockerEngineRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



270
271
272
273
274
275
276
277
278
279
280
281
282
# File 'lib/docker_engine_ruby/resources/images.rb', line 270

def commit(params = {})
  query_params = [:author, :changes, :comment, :container, :pause, :repo, :tag]
  parsed, options = DockerEngineRuby::ImageCommitParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :post,
    path: "commit",
    query: query,
    body: parsed.except(*query_params),
    model: DockerEngineRuby::Models::ImageCommitResponse,
    options: options
  )
end

#delete(name, force: nil, noprune: nil, platforms: nil, request_options: {}) ⇒ Array<DockerEngineRuby::Models::DeleteItem>

Remove an image

Parameters:

Returns:

See Also:



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/docker_engine_ruby/resources/images.rb', line 45

def delete(name, params = {})
  parsed, options = DockerEngineRuby::ImageDeleteParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :delete,
    path: ["images/%1$s", name],
    query: query,
    model: DockerEngineRuby::Internal::Type::ArrayOf[DockerEngineRuby::DeleteItem],
    options: options
  )
end

#get(name, platform: nil, request_options: {}) ⇒ StringIO

Export an image

Parameters:

Returns:

  • (StringIO)

See Also:



295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/docker_engine_ruby/resources/images.rb', line 295

def get(name, params = {})
  parsed, options = DockerEngineRuby::ImageGetParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["images/%1$s/get", name],
    query: query,
    headers: {"accept" => "application/octet-stream"},
    model: StringIO,
    options: options
  )
end

#get_all(names: nil, platform: nil, request_options: {}) ⇒ StringIO

Export several images

Parameters:

Returns:

  • (StringIO)

See Also:



319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/docker_engine_ruby/resources/images.rb', line 319

def get_all(params = {})
  parsed, options = DockerEngineRuby::ImageGetAllParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "images/get",
    query: query,
    headers: {"accept" => "application/octet-stream"},
    model: StringIO,
    options: options
  )
end

#history(name, platform: nil, request_options: {}) ⇒ Array<DockerEngineRuby::Models::HistoryItem>

Get the history of an image

Parameters:

Returns:

See Also:



343
344
345
346
347
348
349
350
351
352
353
# File 'lib/docker_engine_ruby/resources/images.rb', line 343

def history(name, params = {})
  parsed, options = DockerEngineRuby::ImageHistoryParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["images/%1$s/history", name],
    query: query,
    model: DockerEngineRuby::Internal::Type::ArrayOf[DockerEngineRuby::HistoryItem],
    options: options
  )
end

#inspect_(name, manifests: nil, request_options: {}) ⇒ DockerEngineRuby::Models::Image

Inspect an image

Parameters:

Returns:

See Also:



366
367
368
369
370
371
372
373
374
375
376
# File 'lib/docker_engine_ruby/resources/images.rb', line 366

def inspect_(name, params = {})
  parsed, options = DockerEngineRuby::ImageInspectParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["images/%1$s/json", name],
    query: query,
    model: DockerEngineRuby::Image,
    options: options
  )
end

#list(all: nil, digests: nil, filters: nil, manifests: nil, shared_size: nil, request_options: {}) ⇒ Array<DockerEngineRuby::Models::ImageSummary>

List Images

Parameters:

  • all (Boolean)
  • digests (Boolean)
  • filters (String)
  • manifests (Boolean)
  • shared_size (Boolean)
  • request_options (DockerEngineRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/docker_engine_ruby/resources/images.rb', line 20

def list(params = {})
  parsed, options = DockerEngineRuby::ImageListParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "images/json",
    query: query.transform_keys(shared_size: "shared-size"),
    model: DockerEngineRuby::Internal::Type::ArrayOf[DockerEngineRuby::ImageSummary],
    options: options
  )
end

#load_(body:, platform: nil, quiet: nil, request_options: {}) ⇒ nil

Import images

Parameters:

Returns:

  • (nil)

See Also:



393
394
395
396
397
398
399
400
401
402
403
404
405
# File 'lib/docker_engine_ruby/resources/images.rb', line 393

def load_(params)
  parsed, options = DockerEngineRuby::ImageLoadParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed.except(:body))
  @client.request(
    method: :post,
    path: "images/load",
    query: query,
    headers: {"content-type" => "application/octet-stream"},
    body: parsed[:body],
    model: NilClass,
    options: options
  )
end

#prune(filters: nil, request_options: {}) ⇒ DockerEngineRuby::Models::ImagePruneResponse

Delete unused images

Parameters:

Returns:

See Also:



417
418
419
420
421
422
423
424
425
426
427
# File 'lib/docker_engine_ruby/resources/images.rb', line 417

def prune(params = {})
  parsed, options = DockerEngineRuby::ImagePruneParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :post,
    path: "images/prune",
    query: query,
    model: DockerEngineRuby::Models::ImagePruneResponse,
    options: options
  )
end

#pull(body:, changes: nil, from_image: nil, from_src: nil, message: nil, platform: nil, repo: nil, tag: nil, x_registry_auth: nil, request_options: {}) ⇒ nil

Create an image

Parameters:

  • body (String)

    Body param

  • changes (Array<String>)

    Query param

  • from_image (String)

    Query param

  • from_src (String)

    Query param

  • message (String)

    Query param

  • platform (String)

    Query param

  • repo (String)

    Query param

  • tag (String)

    Query param

  • x_registry_auth (String)

    Header param

  • request_options (DockerEngineRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
# File 'lib/docker_engine_ruby/resources/images.rb', line 456

def pull(params)
  query_params = [:changes, :from_image, :from_src, :message, :platform, :repo, :tag]
  parsed, options = DockerEngineRuby::ImagePullParams.dump_request(params)
  @client.request(
    method: :post,
    path: "images/create",
    query: parsed.slice(*query_params).transform_keys(from_image: "fromImage", from_src: "fromSrc"),
    headers: {"content-type" => "text/plain", **parsed.except(:body, *query_params)}.transform_keys(
      x_registry_auth: "x-registry-auth"
    ),
    body: parsed[:body],
    model: NilClass,
    options: options
  )
end

#push(name, x_registry_auth:, platform: nil, tag: nil, request_options: {}) ⇒ nil

Push an image

Parameters:

  • name (String)

    Path param

  • x_registry_auth (String)

    Header param

  • platform (String)

    Query param

  • tag (String)

    Query param

  • request_options (DockerEngineRuby::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



489
490
491
492
493
494
495
496
497
498
499
500
501
# File 'lib/docker_engine_ruby/resources/images.rb', line 489

def push(name, params)
  query_params = [:platform, :tag]
  parsed, options = DockerEngineRuby::ImagePushParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :post,
    path: ["images/%1$s/push", name],
    query: query,
    headers: parsed.except(*query_params).transform_keys(x_registry_auth: "x-registry-auth"),
    model: NilClass,
    options: options
  )
end

#search(term:, filters: nil, limit: nil, request_options: {}) ⇒ Array<DockerEngineRuby::Models::ImageSearchResponseItem>

Search images

Parameters:

Returns:

See Also:



515
516
517
518
519
520
521
522
523
524
525
# File 'lib/docker_engine_ruby/resources/images.rb', line 515

def search(params)
  parsed, options = DockerEngineRuby::ImageSearchParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "images/search",
    query: query,
    model: DockerEngineRuby::Internal::Type::ArrayOf[DockerEngineRuby::Models::ImageSearchResponseItem],
    options: options
  )
end

#tag(name, repo: nil, tag: nil, request_options: {}) ⇒ nil

Tag an image

Parameters:

Returns:

  • (nil)

See Also:



539
540
541
542
543
544
545
546
547
548
549
# File 'lib/docker_engine_ruby/resources/images.rb', line 539

def tag(name, params = {})
  parsed, options = DockerEngineRuby::ImageTagParams.dump_request(params)
  query = DockerEngineRuby::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :post,
    path: ["images/%1$s/tag", name],
    query: query,
    model: NilClass,
    options: options
  )
end