Class: Docker::Volume
Overview
class represents a Docker Volume
Instance Attribute Summary
Attributes included from Base
Class Method Summary collapse
-
.all(opts = {}, conn = Docker.connection) ⇒ Object
/volumes endpoint returns an array of hashes incapsulated in an Volumes tag.
-
.create(name, opts = {}, conn = Docker.connection) ⇒ Object
creates a volume with an arbitrary name.
-
.get(name, conn = Docker.connection) ⇒ Object
get details for a single volume.
- .prune(conn = Docker.connection) ⇒ Object
Instance Method Summary collapse
- #normalize_hash(hash) ⇒ Object
-
#remove(opts = {}, conn = Docker.connection) ⇒ Object
/volumes/volume_name doesnt return anything.
Methods included from Base
Class Method Details
.all(opts = {}, conn = Docker.connection) ⇒ Object
/volumes endpoint returns an array of hashes incapsulated in an Volumes tag
26 27 28 29 30 31 |
# File 'lib/docker/volume.rb', line 26 def all(opts = {}, conn = Docker.connection) resp = conn.get('/volumes') json = Docker::Util.parse_json(resp) || {} hashes = json['Volumes'] || [] hashes.map { |hash| new(conn, hash) } end |
.create(name, opts = {}, conn = Docker.connection) ⇒ Object
creates a volume with an arbitrary name
34 35 36 37 38 39 |
# File 'lib/docker/volume.rb', line 34 def create(name, opts = {}, conn = Docker.connection) opts['Name'] = name resp = conn.post('/volumes/create', {}, body: MultiJson.dump(opts)) hash = Docker::Util.parse_json(resp) || {} new(conn, hash) end |
.get(name, conn = Docker.connection) ⇒ Object
get details for a single volume
19 20 21 22 23 |
# File 'lib/docker/volume.rb', line 19 def get(name, conn = Docker.connection) resp = conn.get("/volumes/#{name}") hash = Docker::Util.parse_json(resp) || {} new(conn, hash) end |
.prune(conn = Docker.connection) ⇒ Object
41 42 43 |
# File 'lib/docker/volume.rb', line 41 def prune(conn = Docker.connection) conn.post("/volumes/prune") end |
Instance Method Details
#normalize_hash(hash) ⇒ Object
12 13 14 |
# File 'lib/docker/volume.rb', line 12 def normalize_hash(hash) hash['id'] ||= hash['Name'] end |
#remove(opts = {}, conn = Docker.connection) ⇒ Object
/volumes/volume_name doesnt return anything
8 9 10 |
# File 'lib/docker/volume.rb', line 8 def remove(opts = {}, conn = Docker.connection) conn.delete("/volumes/#{id}") end |