docker-api 1.16.0 → 1.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +50 -2
- data/lib/docker/image.rb +3 -2
- data/lib/docker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5107a18fb800b02e24fb210eabebb590ebba712
|
4
|
+
data.tar.gz: d6e84d31fcb6a92122534f6abbef33ada1e067db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be210857e2617dfd0afdda61d56cca2ccb175444c3795713ebe5bb2d4af66fc594775c7362485ccac32b0ebb6eceaf3ac79b2d14b97d0c41905d8b1488984dd9
|
7
|
+
data.tar.gz: 710e11510744cd6066519baa481887bccf38ec45138aa4e989f9f66fab42bc74c08921517864706d644ea7cca2f65e29eccc8e99cf94839f7daf911fc3c8ff0e
|
data/README.md
CHANGED
@@ -95,6 +95,7 @@ Docker.authenticate!('username' => 'docker-fan-boi', 'password' => 'i<3docker',
|
|
95
95
|
```
|
96
96
|
|
97
97
|
## Images
|
98
|
+
|
98
99
|
Just about every method here has a one-to-one mapping with the [Images](https://docs.docker.com/reference/api/docker_remote_api_v1.12/#22-images) section of the API. If an API call accepts query parameters, these can be passed as an Hash to it's corresponding method. Also, note that `Docker::Image.new` is a private method, so you must use `.create`, `.build`, `.build_from_dir`, `build_from_tar`, or `.import` to make an instance.
|
99
100
|
|
100
101
|
```ruby
|
@@ -102,7 +103,7 @@ require 'docker'
|
|
102
103
|
# => true
|
103
104
|
|
104
105
|
# Create an Image.
|
105
|
-
Docker::Image.create('fromImage' => 'base')
|
106
|
+
image = Docker::Image.create('fromImage' => 'base')
|
106
107
|
# => Docker::Image { :id => ae7ffbcd1, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
|
107
108
|
|
108
109
|
# Insert a local file into an Image.
|
@@ -182,13 +183,14 @@ Docker::Image.search('term' => 'sshd')
|
|
182
183
|
```
|
183
184
|
|
184
185
|
## Containers
|
186
|
+
|
185
187
|
Much like the Images, this object also has a one-to-one mapping with the [Containers](https://docs.docker.com/reference/api/docker_remote_api_v1.12/#21-containers) section of the API. Also like Images, `.new` is a private method, so you must use `.create` to make an instance.
|
186
188
|
|
187
189
|
```ruby
|
188
190
|
require 'docker'
|
189
191
|
|
190
192
|
# Create a Container.
|
191
|
-
Docker::Container.create('Cmd' => ['ls'], 'Image' => 'base')
|
193
|
+
container = Docker::Container.create('Cmd' => ['ls'], 'Image' => 'base')
|
192
194
|
# => Docker::Container { :id => 492510dd38e4, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
|
193
195
|
|
194
196
|
# Get more information about the Container.
|
@@ -271,6 +273,33 @@ container = Docker::Container.create('Image' => 'base', 'Cmd' => ['cat'], 'OpenS
|
|
271
273
|
container.tap(&:start).attach(stdin: StringIO.new("foo\nbar\n"))
|
272
274
|
# => [["foo\nbar\n"], []]
|
273
275
|
|
276
|
+
# Similar to the stdout/stderr attach method, there is logs and streaming_logs
|
277
|
+
|
278
|
+
# logs will only return after the container has exited. The output will be the raw output from the logs stream.
|
279
|
+
# streaming_logs will collect the messages out of the multiplexed form and also execute a block on each line that comes in (block takes a stream and a chunk as arguments)
|
280
|
+
|
281
|
+
# Raw logs from a TTY-enabled container after exit
|
282
|
+
container.logs(stdout: true)
|
283
|
+
# => "\e]0;root@8866c76564e8: /\aroot@8866c76564e8:/# echo 'i\b \bdocker-api'\r\ndocker-api\r\n\e]0;root@8866c76564e8: /\aroot@8866c76564e8:/# exit\r\n"
|
284
|
+
|
285
|
+
# Logs from a non-TTY container with multiplex prefix
|
286
|
+
container.logs(stdout: true)
|
287
|
+
# => "\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00021\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00022\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00023\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00024\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00025\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00026\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00027\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00028\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u00029\n\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u000310\n"
|
288
|
+
|
289
|
+
# Streaming logs from non-TTY container removing multiplex prefix with a block printing out each line (block not possible with Container#logs)
|
290
|
+
container.streaming_logs(stdout: true) { |stream, chunk| puts "#{stream}: #{chunk}" }
|
291
|
+
stdout: 1
|
292
|
+
stdout: 2
|
293
|
+
stdout: 3
|
294
|
+
stdout: 4
|
295
|
+
stdout: 5
|
296
|
+
stdout: 6
|
297
|
+
stdout: 7
|
298
|
+
stdout: 8
|
299
|
+
stdout: 9
|
300
|
+
stdout: 10
|
301
|
+
# => "1\n\n2\n\n3\n\n4\n\n5\n\n6\n\n7\n\n8\n\n9\n\n10\n"
|
302
|
+
|
274
303
|
# If the container has TTY enabled, set `tty => true` to get the raw stream:
|
275
304
|
command = ["bash", "-c", "if [ -t 1 ]; then echo -n \"I'm a TTY!\"; fi"]
|
276
305
|
container = Docker::Container.create('Image' => 'ubuntu', 'Cmd' => command, 'Tty' => true)
|
@@ -325,6 +354,25 @@ Docker::Container.all(:all => true)
|
|
325
354
|
# => [Docker::Container { :id => , :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }]
|
326
355
|
```
|
327
356
|
|
357
|
+
## Events
|
358
|
+
|
359
|
+
```ruby
|
360
|
+
require 'docker'
|
361
|
+
|
362
|
+
# Action on a stream of events as they come in
|
363
|
+
Docker::Event.stream { |event| puts event; break }
|
364
|
+
Docker::Event { :status => create, :id => aeb8b55726df63bdd69d41e1b2650131d7ce32ca0d2fa5cbc75f24d0df34c7b0, :from => base:latest, :time => 1416958554 }
|
365
|
+
# => nil
|
366
|
+
|
367
|
+
# Action on all events after a given time (will execute the block for all events up till the current time, and wait to execute on any new events after)
|
368
|
+
Docker::Event.since(1416958763) { |event| puts event; puts Time.now.to_i; break }
|
369
|
+
Docker::Event { :status => die, :id => 663005cdeb56f50177c395a817dbc8bdcfbdfbdaef329043b409ecb97fb68d7e, :from => base:latest, :time => 1416958764 }
|
370
|
+
1416959041
|
371
|
+
# => nil
|
372
|
+
```
|
373
|
+
|
374
|
+
These methods are prone to read timeouts. `Docker.options[:read_timeout]` will need to be made higher than 60 seconds if expecting a long time between events.
|
375
|
+
|
328
376
|
## Connecting to Multiple Servers
|
329
377
|
|
330
378
|
By default, each object connects to the connection specified by `Docker.connection`. If you need to connect to multiple servers, you can do so by specifying the connection on `#new` or in the utilizing class method. For example:
|
data/lib/docker/image.rb
CHANGED
@@ -100,8 +100,9 @@ class Docker::Image
|
|
100
100
|
headers = !credentials.nil? && Docker::Util.build_auth_header(credentials)
|
101
101
|
headers ||= {}
|
102
102
|
body = conn.post('/images/create', opts, :headers => headers)
|
103
|
-
|
104
|
-
|
103
|
+
json = Docker::Util.fix_json(body)
|
104
|
+
image = json.reverse_each.find { |el| el && el.key?('id') }
|
105
|
+
new(conn, 'id' => image && image.fetch('id'), :headers => headers)
|
105
106
|
end
|
106
107
|
|
107
108
|
# Return a specific image.
|
data/lib/docker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Swipely, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|