DockerAPI.Image (DockerAPI v0.3.0) View Source

Images

Official document

https://docs.docker.com/engine/api/v1.40/#tag/Image

Link to this section Summary

Functions

DockerAPI.Image.build/3, raising an exception in case of failure.

Create a new image from a container

DockerAPI.Image.commit/3, raising an exception in case of failure.

DockerAPI.Image.create/3, raising an exception in case of failure.

Export an image

Export several images

DockerAPI.Image.export/1, raising an exception in case of failure.

DockerAPI.Image.export/2, raising an exception in case of failure.

Get the history of an image

DockerAPI.Image.history/1, raising an exception in case of failure.

Inspect an image

DockerAPI.Image.inspect/1, raising an exception in case of failure.

DockerAPI.Image.list/2, raising an exception in case of failure.

DockerAPI.Image.load/3, raising an exception in case of failure.

Delete builder cache

DockerAPI.Image.prune_build/1, raising an exception in case of failure.

Delete unused images

DockerAPI.Image.prune_image/2, raising an exception in case of failure.

DockerAPI.Image.push/2, raising an exception in case of failure.

Remove an image

DockerAPI.Image.remove/2, raising an exception in case of failure.

DockerAPI.Image.search/2, raising an exception in case of failure.

DockerAPI.Image.tag/2, raising an exception in case of failure.

Link to this section Functions

Link to this function

build(conn, params \\ [], body \\ "")

View Source

Build an image

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageBuild

Example

Please help!

Link to this function

build!(conn, params \\ [], body \\ "")

View Source

DockerAPI.Image.build/3, raising an exception in case of failure.

Link to this function

commit(conn, params \\ [], body \\ %{})

View Source

Create a new image from a container

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageCommit

Example

Please help!

Link to this function

commit!(conn, params \\ [], body \\ %{})

View Source

DockerAPI.Image.commit/3, raising an exception in case of failure.

Link to this function

create(conn, params \\ [], body \\ "")

View Source

Create an image

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageCreate

Example

Please help!

Link to this function

create!(conn, params \\ [], body \\ "")

View Source

DockerAPI.Image.create/3, raising an exception in case of failure.

Export an image

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageGet

Example

DockerAPI.Connection.new() |> DockerAPI.Image.list!() |> Enum.at(0) |> DockerAPI.Image.export() {:ok, <<98, 102, 55, 53, 54, 102, 98, 49, 97, 101, 54, 53, 97, 100, 102, 56, 54, 54, 98, 100, 56, 99, 52, 53, 54, 53, 57, 51, 99, 100, 50, 52, 98, 101, 98, 54, 97, 48, 97, 48, 54, 49, 100, 101, 100, 102, 52, 50, ...>>}

Link to this function

export(conn, params \\ [])

View Source

Export several images

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageGetAll

Example

DockerAPI.Connection.new() |> DockerAPI.Image.export() {:ok, <<109, 97, 110, 105, 102, 101, 115, 116, 46, 106, 115, 111, 110, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>}

DockerAPI.Image.export/1, raising an exception in case of failure.

Link to this function

export!(conn, params \\ [])

View Source

DockerAPI.Image.export/2, raising an exception in case of failure.

Get the history of an image

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageHistory

Example

DockerAPI.Connection.new() |> DockerAPI.Image.list!() |> Enum.map(&DockerAPI.Image.history/1) [ ok: [

%{
  "Comment" => "",
  "Created" => 1578014497,
  "CreatedBy" => "/bin/sh -c #(nop)  CMD ["/hello"]",
  "Id" => "sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b",
  "Size" => 0,
  "Tags" => ["hello-world:latest"]
},
%{
  "Comment" => "",
  "Created" => 1578014497,
  "CreatedBy" => "/bin/sh -c #(nop) COPY file:7bf12aab75c3867a023fe3b8bd6d113d43a4fcc415f3cc27cbcf0fff37b65a02 in / ",
  "Id" => "<missing>",
  "Size" => 13336,
  "Tags" => nil
}

] ]

DockerAPI.Image.history/1, raising an exception in case of failure.

Inspect an image

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageInspect

Example

DockerAPI.Connection.new() |> DockerAPI.Image.list!() |> Enum.map(&DockerAPI.Image.inspect()/1) [ ok: %{

"Architecture" => "amd64",
"Author" => "",
"Comment" => "",
"Config" => %{
  "ArgsEscaped" => true,
  "AttachStderr" => false,
  "AttachStdin" => false,
  "AttachStdout" => false,
  "Cmd" => ["/hello"],
  "Domainname" => "",
  "Entrypoint" => nil,
  "Env" => ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],
  "Hostname" => "",
  "Image" => "sha256:eb850c6a1aedb3d5c62c3a484ff01b6b4aade130b950e3bf3e9c016f17f70c34",
  "Labels" => nil,
  "OnBuild" => nil,
  "OpenStdin" => false,
  "StdinOnce" => false,
  "Tty" => false,
  "User" => "",
  "Volumes" => nil,
  "WorkingDir" => ""
},
"Container" => "71237a2659e6419aee44fc0b51ffbd12859d1a50ba202e02c2586ed999def583",
"ContainerConfig" => %{
  "ArgsEscaped" => true,
  "AttachStderr" => false,
  "AttachStdin" => false,
  "AttachStdout" => false,
  "Cmd" => ["/bin/sh", "-c", "#(nop) ", "CMD ["/hello"]"],
  "Domainname" => "",
  "Entrypoint" => nil,
  "Env" => ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"],
  "Hostname" => "71237a2659e6",
  "Image" => "sha256:eb850c6a1aedb3d5c62c3a484ff01b6b4aade130b950e3bf3e9c016f17f70c34",
  "Labels" => %{},
  "OnBuild" => nil,
  "OpenStdin" => false,
  "StdinOnce" => false,
  "Tty" => false,
  "User" => "",
  "Volumes" => nil,
  "WorkingDir" => ""
},
"Created" => "2020-01-03T01:21:37.263809283Z",
"DockerVersion" => "18.06.1-ce",
"GraphDriver" => %{
  "Data" => %{
    "MergedDir" => "/var/lib/docker/overlay2/2d9b7f038b1595d500d450ea943dd008108e0ee90593c2d4aafbd2fb76aa1775/merged",
    "UpperDir" => "/var/lib/docker/overlay2/2d9b7f038b1595d500d450ea943dd008108e0ee90593c2d4aafbd2fb76aa1775/diff",
    "WorkDir" => "/var/lib/docker/overlay2/2d9b7f038b1595d500d450ea943dd008108e0ee90593c2d4aafbd2fb76aa1775/work"
  },
  "Name" => "overlay2"
},
"Id" => "sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b",
"Metadata" => %{"LastTagTime" => "0001-01-01T00:00:00Z"},
"Os" => "linux",
"Parent" => "",
"RepoDigests" => ["hello-world@sha256:7f0a9f93b4aa3022c3a4c147a449bf11e0941a1fd0bf4a8e6c9408b2600777c5"],
"RepoTags" => ["hello-world:latest"],
"RootFS" => %{
  "Layers" => ["sha256:9c27e219663c25e0f28493790cc0b88bc973ba3b1686355f221c38a36978ac63"],
  "Type" => "layers"
},
"Size" => 13336,
"VirtualSize" => 13336

} ]

DockerAPI.Image.inspect/1, raising an exception in case of failure.

Link to this function

list(conn, params \\ [])

View Source

List Images

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageList

Example

DockerAPI.Connection.new() |> DockerAPI.Image.list()
{:ok,
[
 %DockerAPI.Image{
   connection: %DockerAPI.Connection{
     headers: [],
     identity_token: nil,
     options: [],
     url: "http+unix://%2Fvar%2Frun%2Fdocker.sock",
     version: nil
   },
   id: "sha256:bf756fb1ae65adf866bd8c456593cd24beb6a0a061dedf42b26a993176745f6b"
 }
]}
Link to this function

list!(conn, params \\ [])

View Source

DockerAPI.Image.list/2, raising an exception in case of failure.

Link to this function

load(conn, params \\ [], body \\ "")

View Source

Import images

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageLoad

Example

Please help!

Link to this function

load!(conn, params \\ [], body \\ "")

View Source

DockerAPI.Image.load/3, raising an exception in case of failure.

Delete builder cache

Official document

https://docs.docker.com/engine/api/v1.40/#operation/BuildPrune

Example

DockerAPI.Connection.new() |> DockerAPI.Image.prune_build() {:ok, %{"CachesDeleted" => nil, "SpaceReclaimed" => 0}}

DockerAPI.Image.prune_build/1, raising an exception in case of failure.

Link to this function

prune_image(conn, params \\ [])

View Source

Delete unused images

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImagePrune

Example

DockerAPI.Connection.new() |> DockerAPI.Image.prune_image() {:ok, %{"ImagesDeleted" => nil, "SpaceReclaimed" => 0}}

Link to this function

prune_image!(conn, params \\ [])

View Source

DockerAPI.Image.prune_image/2, raising an exception in case of failure.

Link to this function

push(image, params \\ [])

View Source

Push an image

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImagePush

Example

Please help!

Link to this function

push!(image, params \\ [])

View Source

DockerAPI.Image.push/2, raising an exception in case of failure.

Link to this function

remove(image, params \\ [])

View Source

Remove an image

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageDelete

Example

TODO: Write later

Link to this function

remove!(image, params \\ [])

View Source

DockerAPI.Image.remove/2, raising an exception in case of failure.

Link to this function

search(conn, params \\ [])

View Source

Search images

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageSearch

Example

DockerAPI.Connection.new() |> DockerAPI.Image.search([term: "ubuntu", limit: 3]) {:ok, [ %{ "description" => "Ubuntu is a Debian-based Linux operating system based on free software.", "is_automated" => false, "is_official" => true, "name" => "ubuntu", "star_count" => 11438 }, %{ "description" => "debootstrap --variant=minbase --components=main,universe --include=inetutils-ping,iproute2 <suite> /", "is_automated" => false, "is_official" => true, "name" => "ubuntu-debootstrap", "star_count" => 44 }, %{ "description" => "Upstart is an event-based replacement for the /sbin/init daemon which starts processes at boot", "is_automated" => false, "is_official" => true, "name" => "ubuntu-upstart", "star_count" => 110 } ]}

Link to this function

search!(conn, params \\ [])

View Source

DockerAPI.Image.search/2, raising an exception in case of failure.

Link to this function

tag(image, params \\ [])

View Source

Tag an image

Official document

https://docs.docker.com/engine/api/v1.40/#operation/ImageTag

Example

Please help!

Link to this function

tag!(image, params \\ [])

View Source

DockerAPI.Image.tag/2, raising an exception in case of failure.