Skip to content

Commit

Permalink
Merge pull request #209 from mikz/patch-1
Browse files Browse the repository at this point in the history
Fix Docker::Image.create when `m` is nil
  • Loading branch information
nahiluhmot committed Dec 3, 2014
2 parents 5ce86d1 + 468db74 commit 807d6de
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/docker/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ def create(opts = {}, creds = nil, conn = Docker.connection)
headers = !credentials.nil? && Docker::Util.build_auth_header(credentials)
headers ||= {}
body = conn.post('/images/create', opts, :headers => headers)
id = Docker::Util.fix_json(body).select { |m| m['id'] }.last['id']
new(conn, 'id' => id, :headers => headers)
json = Docker::Util.fix_json(body)
image = json.reverse_each.find { |el| el && el.key?('id') }
new(conn, 'id' => image && image.fetch('id'), :headers => headers)
end

# Return a specific image.
Expand Down

0 comments on commit 807d6de

Please sign in to comment.