Skip to content

Commit

Permalink
Fix Docker::Image.create when m is nil
Browse files Browse the repository at this point in the history
Sometime when pulling for second time the API responds
with nil somewhere, leading to:

       undefined method `[]' for nil:NilClass
     # /var/lib/gems/2.1.0/gems/docker-api-1.13.7/lib/docker/image.rb:102:in `create'
  • Loading branch information
mikz authored and Michal Cichra committed Nov 5, 2014
1 parent 004f4ab commit c2e5983
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/docker/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ 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']
id = Docker::Util.fix_json(body).reverse.find { |m| m && m.has_key?('id') }.fetch('id')
new(conn, 'id' => id, :headers => headers)
end

Expand Down

0 comments on commit c2e5983

Please sign in to comment.