Class: Docker::API::Volume

Inherits:
Resource show all
Defined in:
lib/docker/api/resources/volume.rb

Overview

A volume on the daemon.

Volumes are identified by name rather than by a generated id, so #id and #name are the same value.

Instance Attribute Summary

Attributes inherited from Resource

#client, #raw

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #hash, #initialize, #partial?, #stale?, #to_s

Constructor Details

This class inherits a constructor from Docker::API::Resource

Instance Method Details

#driverString?

Returns the driver backing this volume.

Returns:

  • (String, nil)

    the driver backing this volume



24
25
26
# File 'lib/docker/api/resources/volume.rb', line 24

def driver
  detail("Driver")
end

#idString?

Returns the volume's name, which is also its identifier.

Returns:

  • (String, nil)

    the volume's name, which is also its identifier



19
20
21
# File 'lib/docker/api/resources/volume.rb', line 19

def id
  name
end

#labelsHash

Returns the volume's labels.

Returns:

  • (Hash)

    the volume's labels



34
35
36
# File 'lib/docker/api/resources/volume.rb', line 34

def labels
  detail("Labels") || {}
end

#mountpointString?

Returns where the daemon keeps the volume's contents.

Returns:

  • (String, nil)

    where the daemon keeps the volume's contents



29
30
31
# File 'lib/docker/api/resources/volume.rb', line 29

def mountpoint
  detail("Mountpoint")
end

#nameString?

Returns the volume's name.

Returns:

  • (String, nil)

    the volume's name



14
15
16
# File 'lib/docker/api/resources/volume.rb', line 14

def name
  raw["Name"]
end

#reloadself

Returns:

  • (self)


39
40
41
# File 'lib/docker/api/resources/volume.rb', line 39

def reload
  replace_raw(operations.volume_inspect(name: name).json)
end

#remove(force: false) ⇒ void

This method returns an undefined value.

Parameters:

  • force (Boolean) (defaults to: false)

    remove even if the driver objects



45
46
47
48
# File 'lib/docker/api/resources/volume.rb', line 45

def remove(force: false)
  operations.volume_delete(name: name, force: force)
  nil
end