Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ image.details("image")

# Return image digest and platform information by contacting the registry.
image.distribution("image")
image.distribution("image", {username: "janedoe", password: "password"}) # private repository

# History
image.history("image")
Expand All @@ -94,7 +95,7 @@ image.tag("current:tag", repo: "new", tag: "tag")
# Push image
image.push("repo:tag") # to dockerhub
image.push("localhost:5000/repo:tag") # to local registry
image.push("private/repo", {tag: "tag"}, {username: "janedoe", password: "password"} # to private repository
image.push("private/repo", {tag: "tag"}, {username: "janedoe", password: "password"}) # to private repository

# Remove image
image.remove("image")
Expand Down
7 changes: 5 additions & 2 deletions lib/docker/api/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ def details name
# @see https://docs.docker.com/engine/api/v1.40/#tag/Distribution
#
# @param name [String]: The ID or name of the image.
def distribution name
@connection.get("/distribution/#{name}/json")
# @param authentication [Hash]: Authentication parameters.
def distribution name, authentication = {}
request = {method: :get, path: "/distribution/#{name}/json"}
request[:headers] = {"X-Registry-Auth" => auth_encoder(authentication)} if authentication.any?
@connection.request(request)
end

##
Expand Down