docker-api 1.26.2 → 1.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc23f00b0653acb770223bb93732fd1c5fc2b271
4
- data.tar.gz: 1107a9c03e159bdf9e088bf7d89c93b074cac97f
3
+ metadata.gz: a402451b60cf3ee27d968b6c406b763ba02fd064
4
+ data.tar.gz: 239c7b7261f471873819ade511325c785e632d0f
5
5
  SHA512:
6
- metadata.gz: 057abba527419ba36ede9fc86770d4aa0d189ab17766cec6c84a1d463d80e400b18af6ac645a95ff67886b253fe6ae29c948797c69cbfa67b239288243d1260d
7
- data.tar.gz: 60cb8cbba5a878137e46e13e5c76b9087e9cdaab010c1c30f322a8a9ef363dcb5a80209cdfb7b6d0fa298e39404953ca82f4047ed51d55acb057770da5389669
6
+ metadata.gz: 68228f7e53d244b754ce9c26c3a2e412c4162595ae4fc069afea00aa5b89a499f205bcd2be5e055a274ce6e1f5ef2a9188dec364c2086505817176c4bb66a737
7
+ data.tar.gz: 128d69692f073e103aeef72af0743d5ab3db5020b770242f8df4964da3b0ec6c88c70e587e25822e0a66c80cd3c6bebfdf05f7fa90d501850960b71272c29df9
@@ -1,18 +1,25 @@
1
1
  sudo: required
2
2
  dist: trusty
3
- cache: bundler
4
3
  language: ruby
4
+ cache: bundler
5
5
  rvm:
6
- - 1.9.3
7
- - 2.0
8
- - 2.1
9
6
  - 2.2
7
+ - 2.1
8
+ - 2.0
9
+ - 1.9.3
10
10
  env:
11
- - DOCKER_VERSION=1.6.2
12
- - DOCKER_VERSION=1.7.1
13
- - DOCKER_VERSION=1.8.3
11
+ - DOCKER_VERSION=1.10.3
14
12
  - DOCKER_VERSION=1.9.1
15
- before_install: ./script/install_dependencies.sh
13
+ - DOCKER_VERSION=1.8.2
14
+ - DOCKER_VERSION=1.7.1
15
+ - DOCKER_VERSION=1.6.2
16
+ matrix:
17
+ fast_finish: true
18
+ before_install:
19
+ - docker --version
20
+ - gem install bundler
16
21
  before_script:
17
- - export PATH=/opt/docker:$PATH
18
- - docker version
22
+ - sudo ./script/install_docker.sh ${DOCKER_VERSION}
23
+ - uname -a
24
+ - docker --version
25
+ - docker info
data/README.md CHANGED
@@ -186,6 +186,10 @@ image.save('my_export.tar')
186
186
  image.save
187
187
  # => "abiglongbinarystring"
188
188
 
189
+ # Stream the contents of the image to a block:
190
+ image.save_stream { |chunk| puts chunk }
191
+ # => nil
192
+
189
193
  # Given a Container's export, creates a new Image.
190
194
  # docker command for reference: docker import some-export.tar
191
195
  Docker::Image.import('some-export.tar')
@@ -210,6 +214,11 @@ Docker::Image.build("from base\nrun touch /test")
210
214
  Docker::Image.build_from_dir('.')
211
215
  # => Docker::Image { :id => 1266dc19e, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
212
216
 
217
+ # Create an Image from a file other than Dockerfile.
218
+ # docker command for reference: docker build -f Dockerfile.Centos .
219
+ Docker::Image.build_from_dir('.', { 'dockerfile' => 'Dockerfile.Centos' })
220
+ # => Docker::Image { :id => 1266dc19e, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
221
+
213
222
  # Create an Image from a Dockerfile and stream the logs
214
223
  Docker::Image.build_from_dir('.') do |v|
215
224
  if (log = JSON.parse(v)) && log.has_key?("stream")
@@ -247,6 +256,11 @@ names = %w( my_image1 my_image2:not_latest )
247
256
  Docker::Image.save(names)
248
257
  # => "abiglongbinarystring"
249
258
 
259
+ # Stream the raw binary data
260
+ names = %w( my_image1 my_image2:not_latest )
261
+ Docker::Image.save_stream(names) { |chunk| puts chunk }
262
+ # => nil
263
+
250
264
  # Search the Docker registry.
251
265
  # docker command for reference: docker search sshd
252
266
  Docker::Image.search('term' => 'sshd')
@@ -429,12 +443,30 @@ Docker::Container.get('500f53b25e6e')
429
443
  # Request all of the Containers. By default, will only return the running Containers.
430
444
  Docker::Container.all(:all => true)
431
445
  # => [Docker::Container { :id => , :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }]
446
+ ```
447
+
448
+ ## JSON encoded values
449
+
450
+ For JSON encoded values, nothing is done implicitly, meaning you need to explicitly call `to_json` on your parameter before the call. For example, to request all of the Containers using a filter:
451
+
452
+ ```ruby
453
+ require 'docker'
432
454
 
433
455
  # Request all of the Containers, filtering by status exited.
434
456
  Docker::Container.all(all: true, filters: { status: ["exited"] }.to_json)
435
457
  # => [Docker::Container { :id => , :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }]
458
+
459
+ # Request all of the Container, filtering by label_name.
460
+ Docker::Container.all(all: true, filters: { label: [ "label_name" ] }.to_json)
461
+ # => [Docker::Container { :id => , :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }]
462
+
463
+ # Request all of the Container, filtering by label label_name that have the value label_value_.
464
+ Docker::Container.all(all: true, filters: { label: [ "label_name=label_value" ] }.to_json)
465
+ # => [Docker::Container { :id => , :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }]
436
466
  ```
437
467
 
468
+ This applies for all parameters that are requested to be JSON encoded by the docker api.
469
+
438
470
  ## Events
439
471
 
440
472
  ```ruby
@@ -486,6 +518,10 @@ image 'repo:new_tag' => 'repo:tag' do
486
518
  end
487
519
  ```
488
520
 
521
+ ## Known issues
522
+
523
+ * If the docker daemon is always responding to your requests with a 400 Bad Request when using UNIX sockets, verify you're running Excon version 0.46.0 or greater. [Link](https://github.com/swipely/docker-api/issues/381)
524
+
489
525
  ## Not supported (yet)
490
526
 
491
527
  * Generating a tarball of images and metadata for a repository specified by a name: https://docs.docker.com/engine/reference/api/docker_remote_api_v1.14/#get-a-tarball-containing-all-images-and-tags-in-a-repository
@@ -112,6 +112,11 @@ module Docker
112
112
  Util.parse_json(connection.get('/info'))
113
113
  end
114
114
 
115
+ # Ping the Docker server.
116
+ def ping(connection = self.connection)
117
+ connection.get('/_ping')
118
+ end
119
+
115
120
  # Login to the Docker registry.
116
121
  def authenticate!(options = {}, connection = self.connection)
117
122
  creds = options.to_json
@@ -134,5 +139,5 @@ module Docker
134
139
  module_function :default_socket_url, :env_url, :url, :url=, :env_options,
135
140
  :options, :options=, :creds, :creds=, :logger, :logger=,
136
141
  :connection, :reset!, :reset_connection!, :version, :info,
137
- :authenticate!, :validate_version!, :ssl_options
142
+ :ping, :authenticate!, :validate_version!, :ssl_options
138
143
  end
@@ -89,6 +89,11 @@ class Docker::Image
89
89
  self.class.save(self.id, filename, connection)
90
90
  end
91
91
 
92
+ # Save the image as a tarball to an IO object.
93
+ def save_stream(opts = {}, &block)
94
+ self.class.save_stream(self.id, opts, connection, &block)
95
+ end
96
+
92
97
  # Update the @info hash, which is the only mutable state in this object.
93
98
  def refresh!
94
99
  img = Docker::Image.all({:all => true}, connection).find { |image|
@@ -133,27 +138,49 @@ class Docker::Image
133
138
  # representation of the binary data. If the filename is not nil, then
134
139
  # return nil.
135
140
  def save(names, filename = nil, conn = Docker.connection)
136
- # By using compare_by_identity we can create a Hash that has
137
- # the same key multiple times.
138
- query = {}
139
- query.compare_by_identity
140
- Array(names).each do |name|
141
- query['names'.dup] = URI.encode(name)
142
- end
143
-
144
141
  if filename
145
- file = File.open(filename, 'wb')
146
- conn.get(
147
- '/images/get', query,
148
- :response_block => response_block_for_save(file)
149
- )
150
- file.close
142
+ File.open(filename, 'wb') do |file|
143
+ save_stream(names, {}, conn, &response_block_for_save(file))
144
+ end
151
145
  nil
152
146
  else
153
- conn.get('/images/get', query)
147
+ string = ''
148
+ save_stream(names, {}, conn, &response_block_for_save(string))
149
+ string
154
150
  end
155
151
  end
156
152
 
153
+ # Stream the contents of Docker image(s) to a block.
154
+ #
155
+ # @param names [String, Array#String] The image(s) you wish to save
156
+ # @param conn [Docker::Connection] The Docker connection to use
157
+ # @yield chunk [String] a chunk of the Docker image(s).
158
+ def save_stream(names, opts = {}, conn = Docker.connection, &block)
159
+ # By using compare_by_identity we can create a Hash that has
160
+ # the same key multiple times.
161
+ query = {}.tap(&:compare_by_identity)
162
+ Array(names).each { |name| query['names'.dup] = URI.encode(name) }
163
+ conn.get(
164
+ '/images/get',
165
+ query,
166
+ opts.merge(:response_block => block)
167
+ )
168
+ nil
169
+ end
170
+
171
+ # Load a tar Image
172
+ def load(tar, opts = {}, conn = Docker.connection, creds = nil, &block)
173
+ headers = build_headers(creds)
174
+ body = ""
175
+ f = File.open(tar,'rb')
176
+ conn.post(
177
+ '/images/load',
178
+ opts,
179
+ :headers => headers,
180
+ :response_block => response_block(body, &block)
181
+ ) { f.read(Excon.defaults[:chunk_size]).to_s }
182
+ end
183
+
157
184
  # Check if an image exists.
158
185
  def exist?(id, opts = {}, conn = Docker.connection)
159
186
  get(id, opts, conn)
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.26.2'
3
+ VERSION = '1.27.0'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
@@ -23,10 +23,8 @@ class Docker::Volume
23
23
  # /volumes endpoint returns an array of hashes incapsulated in an Volumes tag
24
24
  def all(opts = {}, conn = Docker.connection)
25
25
  resp = conn.get('/volumes')
26
- hashes = Docker::Util.parse_json(resp) || []
27
- if hashes.has_key?("Volumes")
28
- hashes = hashes['Volumes']
29
- end
26
+ json = Docker::Util.parse_json(resp) || {}
27
+ hashes = json['Volumes'] || []
30
28
  hashes.map { |hash| new(conn, hash) }
31
29
  end
32
30
 
@@ -0,0 +1,149 @@
1
+ #!/bin/sh
2
+ set -e
3
+
4
+ ### BEGIN INIT INFO
5
+ # Provides: docker
6
+ # Required-Start: $syslog $remote_fs
7
+ # Required-Stop: $syslog $remote_fs
8
+ # Should-Start: cgroupfs-mount cgroup-lite
9
+ # Should-Stop: cgroupfs-mount cgroup-lite
10
+ # Default-Start: 2 3 4 5
11
+ # Default-Stop: 0 1 6
12
+ # Short-Description: Create lightweight, portable, self-sufficient containers.
13
+ # Description:
14
+ # Docker is an open-source project to easily create lightweight, portable,
15
+ # self-sufficient containers from any application. The same container that a
16
+ # developer builds and tests on a laptop can run at scale, in production, on
17
+ # VMs, bare metal, OpenStack clusters, public clouds and more.
18
+ ### END INIT INFO
19
+
20
+ export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
21
+
22
+ BASE=$(basename $0)
23
+
24
+ # modify these in /etc/default/$BASE (/etc/default/docker)
25
+ DOCKER=/usr/bin/$BASE
26
+ # This is the pid file managed by docker itself
27
+ DOCKER_PIDFILE=/var/run/$BASE.pid
28
+ # This is the pid file created/managed by start-stop-daemon
29
+ DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
30
+ DOCKER_LOGFILE=/var/log/$BASE.log
31
+ DOCKER_OPTS=
32
+ DOCKER_DESC="Docker"
33
+
34
+ # Get lsb functions
35
+ . /lib/lsb/init-functions
36
+
37
+ if [ -f /etc/default/$BASE ]; then
38
+ . /etc/default/$BASE
39
+ fi
40
+
41
+ # Check docker is present
42
+ if [ ! -x $DOCKER ]; then
43
+ log_failure_msg "$DOCKER not present or not executable"
44
+ exit 1
45
+ fi
46
+
47
+ check_init() {
48
+ # see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it directly)
49
+ if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
50
+ log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
51
+ exit 1
52
+ fi
53
+ }
54
+
55
+ fail_unless_root() {
56
+ if [ "$(id -u)" != '0' ]; then
57
+ log_failure_msg "$DOCKER_DESC must be run as root"
58
+ exit 1
59
+ fi
60
+ }
61
+
62
+ cgroupfs_mount() {
63
+ # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
64
+ if grep -v '^#' /etc/fstab | grep -q cgroup \
65
+ || [ ! -e /proc/cgroups ] \
66
+ || [ ! -d /sys/fs/cgroup ]; then
67
+ return
68
+ fi
69
+ if ! mountpoint -q /sys/fs/cgroup; then
70
+ mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
71
+ fi
72
+ (
73
+ cd /sys/fs/cgroup
74
+ for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
75
+ mkdir -p $sys
76
+ if ! mountpoint -q $sys; then
77
+ if ! mount -n -t cgroup -o $sys cgroup $sys; then
78
+ rmdir $sys || true
79
+ fi
80
+ fi
81
+ done
82
+ )
83
+ }
84
+
85
+ case "$1" in
86
+ start)
87
+ check_init
88
+
89
+ fail_unless_root
90
+
91
+ cgroupfs_mount
92
+
93
+ touch "$DOCKER_LOGFILE"
94
+ chgrp docker "$DOCKER_LOGFILE"
95
+
96
+ ulimit -n 1048576
97
+ if [ "$BASH" ]; then
98
+ ulimit -u 1048576
99
+ else
100
+ ulimit -p 1048576
101
+ fi
102
+
103
+ log_begin_msg "Starting $DOCKER_DESC: $BASE"
104
+ start-stop-daemon --start --background \
105
+ --no-close \
106
+ --exec "$DOCKER" \
107
+ --pidfile "$DOCKER_SSD_PIDFILE" \
108
+ --make-pidfile \
109
+ -- \
110
+ -d -p "$DOCKER_PIDFILE" \
111
+ $DOCKER_OPTS \
112
+ >> "$DOCKER_LOGFILE" 2>&1
113
+ log_end_msg $?
114
+ ;;
115
+
116
+ stop)
117
+ check_init
118
+ fail_unless_root
119
+ log_begin_msg "Stopping $DOCKER_DESC: $BASE"
120
+ start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE"
121
+ log_end_msg $?
122
+ ;;
123
+
124
+ restart)
125
+ check_init
126
+ fail_unless_root
127
+ docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
128
+ [ -n "$docker_pid" ] \
129
+ && ps -p $docker_pid > /dev/null 2>&1 \
130
+ && $0 stop
131
+ $0 start
132
+ ;;
133
+
134
+ force-reload)
135
+ check_init
136
+ fail_unless_root
137
+ $0 restart
138
+ ;;
139
+
140
+ status)
141
+ check_init
142
+ status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKER" "$DOCKER_DESC"
143
+ ;;
144
+
145
+ *)
146
+ echo "Usage: service docker {start|stop|restart|status}"
147
+ exit 1
148
+ ;;
149
+ esac
@@ -0,0 +1,61 @@
1
+ description "Docker daemon"
2
+
3
+ start on (local-filesystems and net-device-up IFACE!=lo)
4
+ stop on runlevel [!2345]
5
+ limit nofile 524288 1048576
6
+ limit nproc 524288 1048576
7
+
8
+ respawn
9
+
10
+ kill timeout 20
11
+
12
+ pre-start script
13
+ # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
14
+ if grep -v '^#' /etc/fstab | grep -q cgroup \
15
+ || [ ! -e /proc/cgroups ] \
16
+ || [ ! -d /sys/fs/cgroup ]; then
17
+ exit 0
18
+ fi
19
+ if ! mountpoint -q /sys/fs/cgroup; then
20
+ mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
21
+ fi
22
+ (
23
+ cd /sys/fs/cgroup
24
+ for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
25
+ mkdir -p $sys
26
+ if ! mountpoint -q $sys; then
27
+ if ! mount -n -t cgroup -o $sys cgroup $sys; then
28
+ rmdir $sys || true
29
+ fi
30
+ fi
31
+ done
32
+ )
33
+ end script
34
+
35
+ script
36
+ # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
37
+ DOCKER=/usr/bin/$UPSTART_JOB
38
+ DOCKER_OPTS=
39
+ if [ -f /etc/default/$UPSTART_JOB ]; then
40
+ . /etc/default/$UPSTART_JOB
41
+ fi
42
+ exec "$DOCKER" -d $DOCKER_OPTS
43
+ end script
44
+
45
+ # Don't emit "started" event until docker.sock is ready.
46
+ # See https://github.com/docker/docker/issues/6647
47
+ post-start script
48
+ DOCKER_OPTS=
49
+ if [ -f /etc/default/$UPSTART_JOB ]; then
50
+ . /etc/default/$UPSTART_JOB
51
+ fi
52
+ if ! printf "%s" "$DOCKER_OPTS" | grep -qE -e '-H|--host'; then
53
+ while ! [ -e /var/run/docker.sock ]; do
54
+ initctl status $UPSTART_JOB | grep -qE "(stop|respawn)/" && exit 1
55
+ echo "Waiting for /var/run/docker.sock"
56
+ sleep 0.1
57
+ done
58
+ echo "/var/run/docker.sock is up"
59
+ fi
60
+ end script
61
+
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+ set -x
3
+ set -e
4
+
5
+ # argv[0]
6
+ DOCKER_VERSION=$1
7
+
8
+ # disable travis default installation
9
+ service docker stop
10
+ apt-get -y --purge remove docker-engine
11
+
12
+ # install gpg key for docker rpo
13
+ apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv 58118E89F3A912897C070ADBF76221572C52609D
14
+
15
+ # enable docker repo
16
+ echo 'deb "https://apt.dockerproject.org/repo" ubuntu-trusty main' >> /etc/apt/sources.list.d/docker-main.list
17
+ apt-get update -o Dir::Etc::sourcelist='sources.list.d/docker-main.list' -o Dir::Etc::sourceparts='-' -o APT::Get::List-Cleanup='0'
18
+ apt-cache gencaches
19
+
20
+ # install package
21
+ apt-get -y --force-yes install docker-engine=${DOCKER_VERSION}-0~trusty
22
+ echo 'DOCKER_OPTS="-H unix:///var/run/docker.sock --pidfile=/var/run/docker.pid"' > /etc/default/docker
23
+ cat /etc/default/docker
24
+
25
+ # docker 1.6 packages did not come with init files
26
+ if [[ $DOCKER_VERSION == 1.6.* ]]
27
+ then
28
+ cp script/docker.conf /etc/init/docker.conf
29
+ cp script/docker /etc/init.d/docker
30
+ chmod +x /etc/init.d/docker
31
+ else
32
+ service docker stop
33
+ fi
34
+
35
+ service docker start
@@ -133,13 +133,17 @@ describe Docker::Exec do
133
133
  after { container.kill!.remove }
134
134
 
135
135
  it 'returns empty stdout/stderr messages with exitcode' do
136
- expect(subject.start!(:detach => true)).to eq([[],[], 0])
136
+ expect(subject.start!(:detach => true).length).to eq(3)
137
137
  end
138
138
  end
139
139
 
140
140
  context 'when :wait set long time value' do
141
141
  subject {
142
- described_class.create('Container' => container.id, 'Cmd' => %w[date])
142
+ described_class.create(
143
+ 'Container' => container.id,
144
+ 'AttachStdout' => true,
145
+ 'Cmd' => %w[true]
146
+ )
143
147
  }
144
148
  after { container.kill!.remove }
145
149
 
@@ -269,6 +269,28 @@ describe Docker::Image do
269
269
  end
270
270
  end
271
271
 
272
+ describe '#save_stream' do
273
+ let(:image) { Docker::Image.get('busybox') }
274
+ let(:block) { proc { |chunk| puts chunk } }
275
+
276
+ it 'calls the class method' do
277
+ expect(Docker::Image).to receive(:save_stream)
278
+ .with(image.id, instance_of(Hash), instance_of(Docker::Connection))
279
+ image.save_stream(:chunk_size => 1024 * 1024, &block)
280
+ end
281
+ end
282
+
283
+ describe '#load' do
284
+ include_context "local paths"
285
+ let(:file) { File.join(project_dir, 'spec', 'fixtures', 'load.tar') }
286
+ context 'test image upload' do
287
+ it 'load tianon/true image' do
288
+ result = Docker::Image.load(file)
289
+ expect(result).to eq("")
290
+ end
291
+ end
292
+ end
293
+
272
294
  describe '#refresh!' do
273
295
  let(:image) { Docker::Image.create('fromImage' => 'debian:wheezy') }
274
296
 
@@ -311,7 +333,7 @@ describe Docker::Image do
311
333
  it 'sets the id and sends Docker.creds' do
312
334
  allow(Docker).to receive(:creds).and_return(creds)
313
335
  expect(image).to be_a Docker::Image
314
- expect(image.id).to match(/\A[a-fA-F0-9]+\Z/)
336
+ expect(image.id).to match(/\A(sha256:)?[a-fA-F0-9]+\Z/)
315
337
  expect(image.id).to_not include('base')
316
338
  expect(image.id).to_not be_nil
317
339
  expect(image.id).to_not be_empty
@@ -387,6 +409,30 @@ describe Docker::Image do
387
409
  end
388
410
  end
389
411
 
412
+ describe '.save_stream' do
413
+ let(:image) { 'busybox:latest' }
414
+ let(:non_streamed) do
415
+ Docker.connection.get(
416
+ '/images/get',
417
+ 'names' => URI.encode(image)
418
+ )
419
+ end
420
+ let(:streamed) { '' }
421
+ let(:tar_files) do
422
+ proc do |string|
423
+ Gem::Package::TarReader
424
+ .new(StringIO.new(string, 'rb'))
425
+ .map(&:full_name)
426
+ .sort
427
+ end
428
+ end
429
+
430
+ it 'yields each chunk of the image' do
431
+ Docker::Image.save_stream(image) { |chunk| streamed << chunk }
432
+ expect(tar_files.call(streamed)).to eq(tar_files.call(non_streamed))
433
+ end
434
+ end
435
+
390
436
  describe '.exist?' do
391
437
  subject { described_class }
392
438
  let(:exists) { subject.exist?(image_name) }
@@ -1,5 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
+ # Volume requests are actually slow enough to occasionally not work
4
+ # Use sleep statements to manage that
3
5
  describe Docker::Volume, :docker_1_9 do
4
6
  let(:name) { "ArbitraryNameForTheRakeTestVolume" }
5
7
 
@@ -16,7 +18,7 @@ describe Docker::Volume, :docker_1_9 do
16
18
  describe '.get' do
17
19
  let(:volume) { Docker::Volume.get(name) }
18
20
 
19
- before { Docker::Volume.create(name) }
21
+ before { Docker::Volume.create(name); sleep 1 }
20
22
  after { volume.remove }
21
23
 
22
24
  it 'gets volume details' do
@@ -29,13 +31,14 @@ describe Docker::Volume, :docker_1_9 do
29
31
  after { Docker::Volume.get(name).remove }
30
32
 
31
33
  it 'gets a list of volumes' do
32
- expect { Docker::Volume.create(name) }.to change { Docker::Volume.all.length }.by(1)
34
+ expect { Docker::Volume.create(name); sleep 1 }.to change { Docker::Volume.all.length }.by(1)
33
35
  end
34
36
  end
35
37
 
36
38
  describe '#remove' do
37
39
  it 'removes a volume' do
38
40
  volume = Docker::Volume.create(name)
41
+ sleep 1
39
42
  expect { volume.remove }.to change { Docker::Volume.all.length }.by(-1)
40
43
  end
41
44
  end
@@ -183,6 +183,16 @@ describe Docker do
183
183
  end
184
184
  end
185
185
 
186
+ describe '#ping' do
187
+ before { Docker.reset! }
188
+
189
+ let(:ping) { subject.ping}
190
+
191
+ it 'returns the status as a String' do
192
+ expect(ping).to eq('OK')
193
+ end
194
+ end
195
+
186
196
  describe '#authenticate!' do
187
197
  subject { described_class }
188
198
 
Binary file
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.26.2
4
+ version: 1.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swipely, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-24 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -188,7 +188,9 @@ files:
188
188
  - lib/docker/version.rb
189
189
  - lib/docker/volume.rb
190
190
  - lib/excon/middlewares/hijack.rb
191
- - script/install_dependencies.sh
191
+ - script/docker
192
+ - script/docker.conf
193
+ - script/install_docker.sh
192
194
  - spec/docker/connection_spec.rb
193
195
  - spec/docker/container_spec.rb
194
196
  - spec/docker/event_spec.rb
@@ -202,6 +204,7 @@ files:
202
204
  - spec/docker_spec.rb
203
205
  - spec/fixtures/build_from_dir/Dockerfile
204
206
  - spec/fixtures/export.tar
207
+ - spec/fixtures/load.tar
205
208
  - spec/fixtures/top/Dockerfile
206
209
  - spec/spec_helper.rb
207
210
  homepage: https://github.com/swipely/docker-api
@@ -242,6 +245,7 @@ test_files:
242
245
  - spec/docker_spec.rb
243
246
  - spec/fixtures/build_from_dir/Dockerfile
244
247
  - spec/fixtures/export.tar
248
+ - spec/fixtures/load.tar
245
249
  - spec/fixtures/top/Dockerfile
246
250
  - spec/spec_helper.rb
247
251
  has_rdoc:
@@ -1,23 +0,0 @@
1
- #!/bin/bash
2
- set -e
3
-
4
- # Update bundler
5
- gem install bundler
6
-
7
- # Install docker
8
- sudo mkdir -p /opt/docker
9
- sudo curl -fo /opt/docker/docker "https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION}"
10
- sudo chmod +x /opt/docker/docker
11
-
12
- running=0
13
- for x in {1..3}
14
- do
15
- [[ $running != 1 ]] || break
16
- sudo rm -rf /var/run/docker.pid
17
- sudo /opt/docker/docker -d -D &
18
- DOCKER_PID=$!
19
- sleep 5
20
- echo "Checking if docker is running"
21
- ps -p $DOCKER_PID && running=1 || echo "Couldn't start docker, retrying"
22
- done
23
- echo "Docker running, continuing"