DockerAPI.Volume (DockerAPI v0.3.0) View Source
Create and manage persistent storage that can be attached to containers.
Official document
Link to this section Summary
Link to this section Functions
Create a volume
Official document
https://docs.docker.com/engine/api/v1.40/#operation/VolumeCreate
Example
DockerAPI.Connection.new() |> DockerAPI.Volume.create() %DockerAPI.Volume{ connection: %DockerAPI.Connection{ headers: [], identity_token: nil, options: [], url: "http+unix://%2Fvar%2Frun%2Fdocker.sock", version: nil }, name: "4bc26b8879909eea7352997773a24ab5d691a3bbb6153758046a655b8f6774b3" }
Inspect a volume
Official document
https://docs.docker.com/engine/api/v1.40/#operation/VolumeInspect
Example
DockerAPI.Connection.new() |> DockerAPI.Volume.list!() |> Map.get("Volumes") |> Enum.map(&DockerAPI.Volume.inspect/1) [ ok: %{ "CreatedAt" => "2020-10-27T23:10:20+09:00", "Driver" => "local", "Labels" => nil, "Mountpoint" => "/var/lib/docker/volumes/4bc26b8879909eea7352997773a24ab5d691a3bbb6153758046a655b8f6774b3/_data", "Name" => "4bc26b8879909eea7352997773a24ab5d691a3bbb6153758046a655b8f6774b3", "Options" => nil, "Scope" => "local" } ]
List volumes
Official document
https://docs.docker.com/engine/api/v1.40/#operation/VolumeList
Example
DockerAPI.Connection.new() |> DockerAPI.Volume.list() {:ok, %{ "Volumes" => [ %DockerAPI.Volume{
connection: %DockerAPI.Connection{
headers: [],
identity_token: nil,
options: [],
url: "http+unix://%2Fvar%2Frun%2Fdocker.sock",
version: nil
},
name: "4bc26b8879909eea7352997773a24ab5d691a3bbb6153758046a655b8f6774b3"
} ], "Warnings" => nil }}
Delete unused volumes
Official document
https://docs.docker.com/engine/api/v1.40/#operation/VolumePrune
Example
DockerAPI.Connection.new() |> DockerAPI.Volume.prune() {:ok, %{ "SpaceReclaimed" => 0, "VolumesDeleted" => ["4bc26b8879909eea7352997773a24ab5d691a3bbb6153758046a655b8f6774b3"] }}
Remove a volume
Official document
https://docs.docker.com/engine/api/v1.40/#operation/VolumeDelete
Example
DockerAPI.Connection.new() |> DockerAPI.Volume.create!() |> DockerAPI.Volume.remove() :ok