Class: DockerEngineAPI::Resources::Containers

Inherits:
Object
  • Object
show all
Defined in:
lib/docker_engine_api/resources/containers.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Containers

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 Containers.

Parameters:



849
850
851
# File 'lib/docker_engine_api/resources/containers.rb', line 849

def initialize(client:)
  @client = client
end

Instance Method Details

#archive(id, path:, request_options: {}) ⇒ nil

Get a tar archive of a resource in the filesystem of container id.

Parameters:

  • id (String)

    ID or name of the container

  • path (String)

    Resource in the container’s filesystem to archive.

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

Returns:

  • (nil)

See Also:



201
202
203
204
205
206
207
208
209
210
# File 'lib/docker_engine_api/resources/containers.rb', line 201

def archive(id, params)
  parsed, options = DockerEngineAPI::ContainerArchiveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["containers/%1$s/archive", id],
    query: parsed,
    model: NilClass,
    options: options
  )
end

#attach(id, detach_keys: nil, logs: nil, stderr: nil, stdin: nil, stdout: nil, stream: nil, request_options: {}) ⇒ nil

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

Attach to a container to read its output or send it input. You can attach to the same container multiple times and you can reattach to containers that have been detached.

Either the stream or logs parameter must be true for this endpoint to do anything.

See the [documentation for the ‘docker attach` command](docs.docker.com/engine/reference/commandline/attach/) for more details.

### Hijacking

This endpoint hijacks the HTTP connection to transport stdin, stdout, and stderr on the same socket.

This is the response from the daemon for an attach request:

“‘ HTTP/1.1 200 OK Content-Type: application/vnd.docker.raw-stream

STREAM

“‘

After the headers and two new lines, the TCP connection can now be used for raw, bidirectional communication between the client and server.

To hint potential proxies about connection hijacking, the Docker client can also optionally send connection upgrade headers.

For example, the client sends this request to upgrade the connection:

“‘ POST /containers/16253994b7c4/attach?stream=1&stdout=1 HTTP/1.1 Upgrade: tcp Connection: Upgrade “`

The Docker daemon will respond with a ‘101 UPGRADED` response, and will similarly follow with the raw stream:

“‘ HTTP/1.1 101 UPGRADED Content-Type: application/vnd.docker.raw-stream Connection: Upgrade Upgrade: tcp

STREAM

“‘

### Stream format

When the TTY setting is disabled in [‘POST /containers/create`](#operation/ContainerCreate), the HTTP Content-Type header is set to application/vnd.docker.multiplexed-stream and the stream over the hijacked connected is multiplexed to separate out stdout and stderr. The stream consists of a series of frames, each containing a header and a payload.

The header contains the information which the stream writes (stdout or stderr). It also contains the size of the associated frame encoded in the last four bytes (uint32).

It is encoded on the first eight bytes like this:

“‘go header := [8]byte0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4 “`

STREAM_TYPE can be:

  • 0: stdin (is written on stdout)

  • 1: stdout

  • 2: stderr

‘SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of the uint32 size encoded as big endian.

Following the header is the payload, which is the specified number of bytes of STREAM_TYPE.

The simplest way to implement this protocol is the following:

  1. Read 8 bytes.

  2. Choose stdout or stderr depending on the first byte.

  3. Extract the frame size from the last four bytes.

  4. Read the extracted size and output it on the correct output.

  5. Goto 1.

### Stream format when using a TTY

When the TTY setting is enabled in [‘POST /containers/create`](#operation/ContainerCreate), the stream is not multiplexed. The data exchanged over the hijacked connection is simply the raw data from the process PTY and client’s stdin.

Parameters:

  • id (String)

    ID or name of the container

  • detach_keys (String)

    Override the key sequence for detaching a container.Format is a single

  • logs (Boolean)

    Replay previous logs from the container.

  • stderr (Boolean)

    Attach to stderr

  • stdin (Boolean)

    Attach to stdin

  • stdout (Boolean)

    Attach to stdout

  • stream (Boolean)

    Stream attached streams from the time the request was made onwards.

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

Returns:

  • (nil)

See Also:



332
333
334
335
336
337
338
339
340
341
# File 'lib/docker_engine_api/resources/containers.rb', line 332

def attach(id, params = {})
  parsed, options = DockerEngineAPI::ContainerAttachParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/attach", id],
    query: parsed.transform_keys(detach_keys: "detachKeys"),
    model: NilClass,
    options: options
  )
end

#changes(id, request_options: {}) ⇒ Array<DockerEngineAPI::Models::FilesystemChange>

Returns which files in a container’s filesystem have been added, deleted, or modified. The Kind of modification can be one of:

  • 0: Modified (“C”)

  • 1: Added (“A”)

  • 2: Deleted (“D”)

Parameters:

Returns:

See Also:



359
360
361
362
363
364
365
366
# File 'lib/docker_engine_api/resources/containers.rb', line 359

def changes(id, params = {})
  @client.request(
    method: :get,
    path: ["containers/%1$s/changes", id],
    model: DockerEngineAPI::Internal::Type::ArrayOf[DockerEngineAPI::FilesystemChange],
    options: params[:request_options]
  )
end

#create(config:, name: nil, platform: nil, request_options: {}) ⇒ DockerEngineAPI::Models::CreateResponse

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

Create a container

Parameters:

Returns:

See Also:



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/docker_engine_api/resources/containers.rb', line 24

def create(params)
  parsed, options = DockerEngineAPI::ContainerCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "containers/create",
    query: parsed.except(:config),
    body: parsed[:config],
    model: DockerEngineAPI::CreateResponse,
    options: options
  )
end

#delete(id, force: nil, link: nil, v: nil, request_options: {}) ⇒ nil

Remove a container

Parameters:

  • id (String)

    ID or name of the container

  • force (Boolean)

    If the container is running, kill it before removing it.

  • link (Boolean)

    Remove the specified link associated with the container.

  • v (Boolean)

    Remove anonymous volumes associated with the container.

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

Returns:

  • (nil)

See Also:



177
178
179
180
181
182
183
184
185
186
# File 'lib/docker_engine_api/resources/containers.rb', line 177

def delete(id, params = {})
  parsed, options = DockerEngineAPI::ContainerDeleteParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["containers/%1$s", id],
    query: parsed,
    model: NilClass,
    options: options
  )
end

#exec_(id, attach_stderr: nil, attach_stdin: nil, attach_stdout: nil, cmd: nil, console_size: nil, detach_keys: nil, env: nil, privileged: nil, tty: nil, user: nil, working_dir: nil, request_options: {}) ⇒ DockerEngineAPI::Models::ContainerExecResponse

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

Run a command inside a running container.

Parameters:

  • id (String)

    ID or name of container

  • attach_stderr (Boolean)

    Attach to stderr of the exec command.

  • attach_stdin (Boolean)

    Attach to stdin of the exec command.

  • attach_stdout (Boolean)

    Attach to stdout of the exec command.

  • cmd (Array<String>)

    Command to run, as a string or array of strings.

  • console_size (Array<Integer>, nil)

    Initial console size, as an ‘[height, width]` array.

  • detach_keys (String)

    Override the key sequence for detaching a container. Format is

  • env (Array<String>)

    A list of environment variables in the form ‘[“VAR=value”, …]`.

  • privileged (Boolean)

    Runs the exec process with extended privileges.

  • tty (Boolean)

    Allocate a pseudo-TTY.

  • user (String)

    The user, and optionally, group to run the exec process inside

  • working_dir (String)

    The working directory for the exec process inside the container.

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

Returns:

See Also:



404
405
406
407
408
409
410
411
412
413
# File 'lib/docker_engine_api/resources/containers.rb', line 404

def exec_(id, params = {})
  parsed, options = DockerEngineAPI::ContainerExecParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/exec", id],
    body: parsed,
    model: DockerEngineAPI::Models::ContainerExecResponse,
    options: options
  )
end

#export(id, request_options: {}) ⇒ nil

Export the contents of a container as a tarball.

Parameters:

Returns:

  • (nil)

See Also:



426
427
428
429
430
431
432
433
# File 'lib/docker_engine_api/resources/containers.rb', line 426

def export(id, params = {})
  @client.request(
    method: :get,
    path: ["containers/%1$s/export", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#inspect_(id, size: nil, request_options: {}) ⇒ DockerEngineAPI::Models::Container

Return low-level information about a container.

Parameters:

  • id (String)

    ID or name of the container

  • size (Boolean)

    Return the size of container as fields SizeRw and SizeRootFs

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

Returns:

See Also:



448
449
450
451
452
453
454
455
456
457
# File 'lib/docker_engine_api/resources/containers.rb', line 448

def inspect_(id, params = {})
  parsed, options = DockerEngineAPI::ContainerInspectParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["containers/%1$s/json", id],
    query: parsed,
    model: DockerEngineAPI::Container,
    options: options
  )
end

#kill(id, signal: nil, request_options: {}) ⇒ nil

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

Send a POSIX signal to a container, defaulting to killing to the container.

Parameters:

  • id (String)

    ID or name of the container

  • signal (String)

    Signal to send to the container as an integer or string (e.g. SIGINT).

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

Returns:

  • (nil)

See Also:



475
476
477
478
479
480
481
482
483
484
# File 'lib/docker_engine_api/resources/containers.rb', line 475

def kill(id, params = {})
  parsed, options = DockerEngineAPI::ContainerKillParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/kill", id],
    query: parsed,
    model: NilClass,
    options: options
  )
end

#list(all: nil, filters: nil, limit: nil, size: nil, request_options: {}) ⇒ Array<DockerEngineAPI::Models::Summary>

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

Returns a list of containers. For details on the format, see the [inspect endpoint](#operation/ContainerInspect).

Note that it uses a different, smaller representation of a container than inspecting a single container. For example, the list of linked containers is not propagated .

Parameters:

  • all (Boolean)

    Return all containers. By default, only running containers are shown.

  • filters (String)

    Filters to process on the container list, encoded as JSON (a

  • limit (Integer)

    Return this number of most recently created containers, including

  • size (Boolean)

    Return the size of container as fields SizeRw and SizeRootFs.

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

Returns:

See Also:



149
150
151
152
153
154
155
156
157
158
# File 'lib/docker_engine_api/resources/containers.rb', line 149

def list(params = {})
  parsed, options = DockerEngineAPI::ContainerListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "containers/json",
    query: parsed,
    model: DockerEngineAPI::Internal::Type::ArrayOf[DockerEngineAPI::Summary],
    options: options
  )
end

#logs(id, follow: nil, since: nil, stderr: nil, stdout: nil, tail: nil, timestamps: nil, until_: nil, request_options: {}) ⇒ StringIO

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

Get stdout and stderr logs from a container.

Note: This endpoint works only for containers with the json-file or journald logging driver.

Parameters:

  • id (String)

    ID or name of the container

  • follow (Boolean)

    Keep connection after returning logs.

  • since (Integer)

    Only return logs since this time, as a UNIX timestamp

  • stderr (Boolean)

    Return logs from stderr

  • stdout (Boolean)

    Return logs from stdout

  • tail (String)

    Only return this number of log lines from the end of the logs.

  • timestamps (Boolean)

    Add timestamps to every log line

  • until_ (Integer)

    Only return logs before this time, as a UNIX timestamp

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

Returns:

  • (StringIO)

See Also:



517
518
519
520
521
522
523
524
525
526
527
# File 'lib/docker_engine_api/resources/containers.rb', line 517

def logs(id, params = {})
  parsed, options = DockerEngineAPI::ContainerLogsParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["containers/%1$s/logs", id],
    query: parsed.transform_keys(until_: "until"),
    headers: {"accept" => "application/vnd.docker.multiplexed-stream"},
    model: StringIO,
    options: options
  )
end

#pause(id, request_options: {}) ⇒ nil

Use the freezer cgroup to suspend all processes in a container.

Traditionally, when suspending a process the SIGSTOP signal is used, which is observable by the process being suspended. With the freezer cgroup the process is unaware, and unable to capture, that it is being suspended, and subsequently resumed.

Parameters:

Returns:

  • (nil)

See Also:



545
546
547
548
549
550
551
552
# File 'lib/docker_engine_api/resources/containers.rb', line 545

def pause(id, params = {})
  @client.request(
    method: :post,
    path: ["containers/%1$s/pause", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#prune(filters: nil, request_options: {}) ⇒ DockerEngineAPI::Models::ContainerPruneResponse

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

Delete stopped containers

Parameters:

  • filters (String)

    Filters to process on the prune list, encoded as JSON (a map[string][]string).

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

Returns:

See Also:



568
569
570
571
572
573
574
575
576
577
# File 'lib/docker_engine_api/resources/containers.rb', line 568

def prune(params = {})
  parsed, options = DockerEngineAPI::ContainerPruneParams.dump_request(params)
  @client.request(
    method: :post,
    path: "containers/prune",
    query: parsed,
    model: DockerEngineAPI::Models::ContainerPruneResponse,
    options: options
  )
end

#rename(id, name:, request_options: {}) ⇒ nil

Rename a container

Parameters:

  • id (String)

    ID or name of the container

  • name (String)

    New name for the container

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

Returns:

  • (nil)

See Also:



592
593
594
595
596
597
598
599
600
601
# File 'lib/docker_engine_api/resources/containers.rb', line 592

def rename(id, params)
  parsed, options = DockerEngineAPI::ContainerRenameParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/rename", id],
    query: parsed,
    model: NilClass,
    options: options
  )
end

#resize(id, h:, w:, request_options: {}) ⇒ nil

Resize the TTY for a container.

Parameters:

  • id (String)

    ID or name of the container

  • h (Integer)

    Height of the TTY session in characters

  • w (Integer)

    Width of the TTY session in characters

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

Returns:

  • (nil)

See Also:



618
619
620
621
622
623
624
625
626
627
# File 'lib/docker_engine_api/resources/containers.rb', line 618

def resize(id, params)
  parsed, options = DockerEngineAPI::ContainerResizeParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/resize", id],
    query: parsed,
    model: NilClass,
    options: options
  )
end

#restart(id, signal: nil, t: nil, request_options: {}) ⇒ nil

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

Restart a container

Parameters:

  • id (String)

    ID or name of the container

  • signal (String)

    Signal to send to the container as an integer or string (e.g. SIGINT).

  • t (Integer)

    Number of seconds to wait before killing the container

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

Returns:

  • (nil)

See Also:



647
648
649
650
651
652
653
654
655
656
# File 'lib/docker_engine_api/resources/containers.rb', line 647

def restart(id, params = {})
  parsed, options = DockerEngineAPI::ContainerRestartParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/restart", id],
    query: parsed,
    model: NilClass,
    options: options
  )
end

#start(id, detach_keys: nil, request_options: {}) ⇒ nil

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

Start a container

Parameters:

  • id (String)

    ID or name of the container

  • detach_keys (String)

    Override the key sequence for detaching a container. Format is a

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

Returns:

  • (nil)

See Also:



674
675
676
677
678
679
680
681
682
683
# File 'lib/docker_engine_api/resources/containers.rb', line 674

def start(id, params = {})
  parsed, options = DockerEngineAPI::ContainerStartParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/start", id],
    query: parsed.transform_keys(detach_keys: "detachKeys"),
    model: NilClass,
    options: options
  )
end

#stats(id, one_shot: nil, stream: nil, request_options: {}) ⇒ DockerEngineAPI::Models::StatsResponse

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

This endpoint returns a live stream of a container’s resource usage statistics.

The precpu_stats is the CPU statistic of the previous read, and is used to calculate the CPU usage percentage. It is not an exact copy of the cpu_stats field.

If either precpu_stats.online_cpus or cpu_stats.online_cpus is nil then for compatibility with older daemons the length of the corresponding cpu_usage.percpu_usage array should be used.

On a cgroup v2 host, the following fields are not set

  • blkio_stats: all fields other than io_service_bytes_recursive

  • cpu_stats: cpu_usage.percpu_usage

  • memory_stats: max_usage and failcnt Also, memory_stats.stats fields are incompatible with cgroup v1.

To calculate the values shown by the stats command of the docker cli tool the following formulas can be used:

  • used_memory = ‘memory_stats.usage - memory_stats.stats.cache` (cgroups v1)

  • used_memory = ‘memory_stats.usage - memory_stats.stats.inactive_file` (cgroups v2)

  • available_memory = memory_stats.limit

  • Memory usage % = ‘(used_memory / available_memory) * 100.0`

  • cpu_delta = ‘cpu_stats.cpu_usage.total_usage - precpu_stats.cpu_usage.total_usage`

  • system_cpu_delta = ‘cpu_stats.system_cpu_usage - precpu_stats.system_cpu_usage`

  • number_cpus = ‘length(cpu_stats.cpu_usage.percpu_usage)` or cpu_stats.online_cpus

  • CPU usage % = ‘(cpu_delta / system_cpu_delta) * number_cpus * 100.0`

Parameters:

  • id (String)

    ID or name of the container

  • one_shot (Boolean)

    Only get a single stat instead of waiting for 2 cycles. Must be used

  • stream (Boolean)

    Stream the output. If false, the stats will be output once and then

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

Returns:

See Also:



734
735
736
737
738
739
740
741
742
743
# File 'lib/docker_engine_api/resources/containers.rb', line 734

def stats(id, params = {})
  parsed, options = DockerEngineAPI::ContainerStatsParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["containers/%1$s/stats", id],
    query: parsed.transform_keys(one_shot: "one-shot"),
    model: DockerEngineAPI::StatsResponse,
    options: options
  )
end

#stop(id, signal: nil, t: nil, request_options: {}) ⇒ nil

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

Stop a container

Parameters:

  • id (String)

    ID or name of the container

  • signal (String)

    Signal to send to the container as an integer or string (e.g. SIGINT).

  • t (Integer)

    Number of seconds to wait before killing the container

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

Returns:

  • (nil)

See Also:



763
764
765
766
767
768
769
770
771
772
# File 'lib/docker_engine_api/resources/containers.rb', line 763

def stop(id, params = {})
  parsed, options = DockerEngineAPI::ContainerStopParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/stop", id],
    query: parsed,
    model: NilClass,
    options: options
  )
end

#top(id, ps_args: nil, request_options: {}) ⇒ DockerEngineAPI::Models::TopResponse

On Unix systems, this is done by running the ps command. This endpoint is not supported on Windows.

Parameters:

  • id (String)

    ID or name of the container

  • ps_args (String)

    The arguments to pass to ps. For example, aux

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

Returns:

See Also:



788
789
790
791
792
793
794
795
796
797
# File 'lib/docker_engine_api/resources/containers.rb', line 788

def top(id, params = {})
  parsed, options = DockerEngineAPI::ContainerTopParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["containers/%1$s/top", id],
    query: parsed,
    model: DockerEngineAPI::TopResponse,
    options: options
  )
end

#unpause(id, request_options: {}) ⇒ nil

Resume a container which has been paused.

Parameters:

Returns:

  • (nil)

See Also:



810
811
812
813
814
815
816
817
# File 'lib/docker_engine_api/resources/containers.rb', line 810

def unpause(id, params = {})
  @client.request(
    method: :post,
    path: ["containers/%1$s/unpause", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#update(id, blkio_device_read_bps: nil, blkio_device_read_i_ops: nil, blkio_device_write_bps: nil, blkio_device_write_i_ops: nil, blkio_weight: nil, blkio_weight_device: nil, cgroup_parent: nil, cpu_count: nil, cpu_percent: nil, cpu_period: nil, cpu_quota: nil, cpu_realtime_period: nil, cpu_realtime_runtime: nil, cpuset_cpus: nil, cpuset_mems: nil, cpu_shares: nil, device_cgroup_rules: nil, device_requests: nil, devices: nil, init: nil, io_maximum_bandwidth: nil, io_maximum_i_ops: nil, memory: nil, memory_reservation: nil, memory_swap: nil, memory_swappiness: nil, nano_cpus: nil, oom_kill_disable: nil, pids_limit: nil, restart_policy: nil, ulimits: nil, request_options: {}) ⇒ DockerEngineAPI::Models::UpdateResponse

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

Change various configuration options of a container without having to recreate it.

Parameters:

  • id (String)

    ID or name of the container

  • blkio_device_read_bps (Array<DockerEngineAPI::Models::ContainerUpdateParams::BlkioDeviceReadBp>)

    Limit read rate (bytes per second) from a device, in the form:

  • blkio_device_read_i_ops (Array<DockerEngineAPI::Models::ContainerUpdateParams::BlkioDeviceReadIOp>)

    Limit read rate (IO per second) from a device, in the form:

  • blkio_device_write_bps (Array<DockerEngineAPI::Models::ContainerUpdateParams::BlkioDeviceWriteBp>)

    Limit write rate (bytes per second) to a device, in the form:

  • blkio_device_write_i_ops (Array<DockerEngineAPI::Models::ContainerUpdateParams::BlkioDeviceWriteIOp>)

    Limit write rate (IO per second) to a device, in the form:

  • blkio_weight (Integer)

    Block IO weight (relative weight).

  • blkio_weight_device (Array<DockerEngineAPI::Models::ContainerUpdateParams::BlkioWeightDevice>)

    Block IO weight (relative device weight) in the form:

  • cgroup_parent (String)

    Path to cgroups under which the container’s cgroup is created. If

  • cpu_count (Integer)

    The number of usable CPUs (Windows only).

  • cpu_percent (Integer)

    The usable percentage of the available CPUs (Windows only).

  • cpu_period (Integer)

    The length of a CPU period in microseconds.

  • cpu_quota (Integer)

    Microseconds of CPU time that the container can get in a CPU period.

  • cpu_realtime_period (Integer)

    The length of a CPU real-time period in microseconds. Set to 0 to

  • cpu_realtime_runtime (Integer)

    The length of a CPU real-time runtime in microseconds. Set to 0 to

  • cpuset_cpus (String)

    CPUs in which to allow execution (e.g., 0-3, ‘0,1`).

  • cpuset_mems (String)

    Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only

  • cpu_shares (Integer)

    An integer value representing this container’s relative CPU weight

  • device_cgroup_rules (Array<String>)

    a list of cgroup rules to apply to the container

  • device_requests (Array<DockerEngineAPI::Models::ContainerUpdateParams::DeviceRequest>)

    A list of requests for devices to be sent to device drivers.

  • devices (Array<DockerEngineAPI::Models::ContainerUpdateParams::Device>)

    A list of devices to add to the container.

  • init (Boolean, nil)

    Run an init inside the container that forwards signals and reaps

  • io_maximum_bandwidth (Integer)

    Maximum IO in bytes per second for the container system drive

  • io_maximum_i_ops (Integer)

    Maximum IOps for the container system drive (Windows only)

  • memory (Integer)

    Memory limit in bytes.

  • memory_reservation (Integer)

    Memory soft limit in bytes.

  • memory_swap (Integer)

    Total memory limit (memory + swap). Set as -1 to enable unlimited

  • memory_swappiness (Integer)

    Tune a container’s memory swappiness behavior. Accepts an integer

  • nano_cpus (Integer)

    CPU quota in units of 10<sup>-9</sup> CPUs.

  • oom_kill_disable (Boolean)

    Disable OOM Killer for the container.

  • pids_limit (Integer, nil)

    Tune a container’s PIDs limit. Set 0 or -1 for unlimited, or null

  • restart_policy (DockerEngineAPI::Models::ContainerUpdateParams::RestartPolicy)

    The behavior to apply when the container exits. The default is not to

  • ulimits (Array<DockerEngineAPI::Models::ContainerUpdateParams::Ulimit>)

    A list of resource limits to set in the container. For example:

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

Returns:

See Also:



113
114
115
116
117
118
119
120
121
122
# File 'lib/docker_engine_api/resources/containers.rb', line 113

def update(id, params = {})
  parsed, options = DockerEngineAPI::ContainerUpdateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/update", id],
    body: parsed,
    model: DockerEngineAPI::UpdateResponse,
    options: options
  )
end

#wait(id, condition: nil, request_options: {}) ⇒ DockerEngineAPI::Models::WaitResponse

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

Block until a container stops, then returns the exit code.

Parameters:

Returns:

See Also:



835
836
837
838
839
840
841
842
843
844
# File 'lib/docker_engine_api/resources/containers.rb', line 835

def wait(id, params = {})
  parsed, options = DockerEngineAPI::ContainerWaitParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["containers/%1$s/wait", id],
    query: parsed,
    model: DockerEngineAPI::WaitResponse,
    options: options
  )
end