docker-api 1.18.0 → 1.19.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 +4 -4
- data/README.md +7 -7
- data/lib/docker/exec.rb +8 -2
- data/lib/docker/util.rb +11 -1
- data/lib/docker/version.rb +2 -2
- data/spec/docker/container_spec.rb +6 -5
- data/spec/docker/exec_spec.rb +29 -61
- data/spec/docker/image_spec.rb +8 -4
- data/spec/docker_spec.rb +4 -3
- data/spec/fixtures/build_from_dir/Dockerfile +1 -1
- data/spec/vcr/Docker/_authenticate_/with_valid_credentials/logs_in_and_sets_the_creds.yml +10 -9
- data/spec/vcr/Docker/_info/returns_the_info_as_a_Hash.yml +15 -9
- data/spec/vcr/Docker/_validate_version/when_nothing_is_raised/validate_version_/.yml +15 -9
- data/spec/vcr/Docker/_version/returns_the_version_as_a_Hash.yml +10 -9
- data/spec/vcr/Docker_Container/_all/when_the_HTTP_response_is_a_200/materializes_each_Container_into_a_Docker_Container.yml +45 -34
- data/spec/vcr/Docker_Container/_attach/with_normal_sized_chunks/yields_each_chunk.yml +31 -30
- data/spec/vcr/Docker_Container/_attach/with_very_small_chunks/yields_each_chunk.yml +31 -30
- data/spec/vcr/Docker_Container/_changes/returns_the_changes_as_an_array.yml +45 -42
- data/spec/vcr/Docker_Container/_commit/creates_a_new_Image_from_the_Container_s_changes.yml +66 -35
- data/spec/vcr/Docker_Container/_copy/when_the_file_does_not_exist/raises_an_error.yml +37 -35
- data/spec/vcr/Docker_Container/_copy/when_the_input_is_a_directory/yields_each_chunk_of_the_tarred_directory.yml +45 -43
- data/spec/vcr/Docker_Container/_copy/when_the_input_is_a_file/yields_each_chunk_of_the_tarred_file.yml +44 -42
- data/spec/vcr/Docker_Container/_create/when_creating_a_container_named_bob/should_have_name_set_to_bob.yml +24 -22
- data/spec/vcr/Docker_Container/_create/when_the_Container_does_not_yet_exist/when_the_HTTP_request_returns_a_200/sets_the_id.yml +15 -14
- data/spec/vcr/Docker_Container/_delete/deletes_the_container.yml +24 -22
- data/spec/vcr/Docker_Container/_exec/when_detach_is_true/returns_the_Docker_Exec_object.yml +68 -39
- data/spec/vcr/Docker_Container/_exec/when_passed_a_block/streams_the_stdout/stderr_messages.yml +68 -38
- data/spec/vcr/Docker_Container/_exec/when_passed_only_a_command/returns_the_stdout/stderr_messages_and_exit_code.yml +183 -0
- data/spec/vcr/Docker_Container/_exec/when_stdin_object_is_passed/returns_the_stdout/stderr_messages.yml +26 -25
- data/spec/vcr/Docker_Container/_exec/when_tty_is_true/returns_the_raw_stdout/stderr_output.yml +68 -38
- data/spec/vcr/Docker_Container/_export/yields_each_chunk.yml +85 -92
- data/spec/vcr/Docker_Container/_get/when_the_HTTP_response_is_a_200/materializes_the_Container_into_a_Docker_Container.yml +24 -22
- data/spec/vcr/Docker_Container/_json/returns_the_description_as_a_Hash.yml +24 -22
- data/spec/vcr/Docker_Container/_kill/kills_the_container.yml +48 -43
- data/spec/vcr/Docker_Container/_kill/with_a_kill_signal/kills_the_container.yml +83 -69
- data/spec/vcr/Docker_Container/_logs/when_not_selecting_any_stream/raises_a_client_error.yml +47 -42
- data/spec/vcr/Docker_Container/_logs/when_selecting_stdout/returns_blank_logs.yml +20 -19
- data/spec/vcr/Docker_Container/_pause/pauses_the_container.yml +45 -43
- data/spec/vcr/Docker_Container/_restart/restarts_the_container.yml +73 -65
- data/spec/vcr/Docker_Container/_run/when_the_Container_s_command_does_not_return_status_code_of_0/raises_an_error.yml +29 -27
- data/spec/vcr/Docker_Container/_run/when_the_Container_s_command_returns_a_status_code_of_0/creates_a_new_container_to_run_the_specified_command.yml +114 -102
- data/spec/vcr/Docker_Container/_start/starts_the_container.yml +42 -37
- data/spec/vcr/Docker_Container/_stop/stops_the_container.yml +49 -44
- data/spec/vcr/Docker_Container/_streaming_logs/when_not_selecting_any_stream/raises_a_client_error.yml +47 -42
- data/spec/vcr/Docker_Container/_streaming_logs/when_selecting_stdout/returns_blank_logs.yml +20 -19
- data/spec/vcr/Docker_Container/_top/returns_the_top_commands_as_an_Array.yml +54 -51
- data/spec/vcr/Docker_Container/_unpause/unpauses_the_container.yml +45 -43
- data/spec/vcr/Docker_Container/_wait/waits_for_the_command_to_finish.yml +29 -27
- data/spec/vcr/Docker_Container/_wait/when_an_argument_is_given/sets_the_read_timeout_to_that_amount_of_time.yml +29 -27
- data/spec/vcr/Docker_Exec/_create/when_the_HTTP_request_returns_a_201/sets_the_id.yml +35 -33
- data/spec/vcr/Docker_Exec/_json/returns_the_description_as_a_Hash.yml +207 -0
- data/spec/vcr/Docker_Exec/_start_/when_detach_is_set_to_false/block_is_passed/attaches_to_the_stream.yml +68 -38
- data/spec/vcr/Docker_Exec/_start_/when_detach_is_set_to_false/returns_the_stdout_and_stderr_messages.yml +68 -38
- data/spec/vcr/Docker_Exec/_start_/when_detach_is_set_to_true/returns_empty_stdout/stderr_messages_with_exitcode.yml +180 -0
- data/spec/vcr/Docker_Exec/_start_/when_the_HTTP_request_returns_a_201/starts_the_exec_instance.yml +67 -38
- data/spec/vcr/Docker_Exec/_start_/when_the_command_has_already_run/raises_an_error.yml +67 -38
- data/spec/vcr/Docker_Image/_all/materializes_each_Image_into_a_Docker_Image.yml +67 -87
- data/spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/with_a_block_capturing_build_output/calls_the_block_and_passes_build_output.yml +9 -9
- data/spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/with_specifying_a_repo_in_the_query_parameters/builds_an_image_and_tags_it.yml +92 -107
- data/spec/vcr/Docker_Image/_build/with_a_valid_Dockerfile/without_query_parameters/builds_an_image.yml +9 -9
- data/spec/vcr/Docker_Image/_build/with_an_invalid_Dockerfile/throws_a_UnexpectedResponseError.yml +11 -9
- data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_a_block_capturing_build_output/calls_the_block_and_passes_build_output.yml +89 -38
- data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_credentials_passed/sends_X-Registry-Config_header.yml +89 -38
- data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_no_query_parameters/builds_the_image.yml +421 -51
- data/spec/vcr/Docker_Image/_build_from_dir/with_a_valid_Dockerfile/with_specifying_a_repo_in_the_query_parameters/builds_the_image_and_tags_it.yml +422 -140
- data/spec/vcr/Docker_Image/_create/when_the_Image_does_not_yet_exist_and_the_body_is_a_Hash/sets_the_id_and_sends_Docker_creds.yml +16 -16
- data/spec/vcr/Docker_Image/_create/with_a_block_capturing_create_output/calls_the_block_and_passes_build_output.yml +9 -7
- data/spec/vcr/Docker_Image/_exist_/when_the_image_does_exist/returns_true.yml +11 -9
- data/spec/vcr/Docker_Image/_get/when_the_image_does_exist/returns_the_new_image.yml +11 -9
- data/spec/vcr/Docker_Image/_history/returns_the_history_of_the_Image.yml +21 -18
- data/spec/vcr/Docker_Image/_import/when_the_argument_is_a_URI/when_the_URI_is_invalid/raises_an_error.yml +164 -35
- data/spec/vcr/Docker_Image/_import/when_the_argument_is_a_URI/when_the_URI_is_valid/returns_an_Image.yml +21 -23
- data/spec/vcr/Docker_Image/_import/when_the_file_does_exist/creates_the_Image.yml +15 -15
- data/spec/vcr/Docker_Image/_insert_local/when_a_direcory_is_passed/inserts_the_directory.yml +887 -840
- data/spec/vcr/Docker_Image/_insert_local/when_removing_intermediate_containers/creates_a_new_image.yml +76 -65
- data/spec/vcr/Docker_Image/_insert_local/when_removing_intermediate_containers/leave_no_intermediate_containers.yml +56 -48
- data/spec/vcr/Docker_Image/_insert_local/when_the_local_file_does_exist/creates_a_new_Image_that_has_that_file.yml +63 -61
- data/spec/vcr/Docker_Image/_insert_local/when_the_local_file_does_not_exist/raises_an_error.yml +9 -9
- data/spec/vcr/Docker_Image/_insert_local/when_there_are_multiple_files_passed/creates_a_new_Image_that_has_each_file.yml +69 -66
- data/spec/vcr/Docker_Image/_json/returns_additional_information_about_image_image.yml +19 -17
- data/spec/vcr/Docker_Image/_push/pushes_the_Image.yml +99 -113
- data/spec/vcr/Docker_Image/_push/streams_output_from_push.yml +100 -391
- data/spec/vcr/Docker_Image/_push/when_the_image_was_retrived_by_get/when_no_tag_is_specified/looks_up_the_first_repo_tag.yml +174 -708
- data/spec/vcr/Docker_Image/_push/when_there_are_no_credentials/still_pushes.yml +115 -110
- data/spec/vcr/Docker_Image/_refresh_/updates_the_info_hash.yml +77 -93
- data/spec/vcr/Docker_Image/_refresh_/with_an_explicit_connection/updates_using_the_provided_connection.yml +19 -17
- data/spec/vcr/Docker_Image/_remove/when_no_name_is_given/removes_the_Image.yml +581 -229
- data/spec/vcr/Docker_Image/_run/when_the_argument_is_a_String/splits_the_String_by_spaces_and_creates_a_new_Container.yml +52 -50
- data/spec/vcr/Docker_Image/_run/when_the_argument_is_an_Array/creates_a_new_Container.yml +42 -40
- data/spec/vcr/Docker_Image/_run/when_the_argument_is_nil/command_configured_in_image/should_normally_show_result_if_image_has_Cmd_configured.yml +52 -50
- data/spec/vcr/Docker_Image/_run/when_the_argument_is_nil/no_command_configured_in_image/should_raise_an_error_if_no_command_is_specified.yml +16 -15
- data/spec/vcr/Docker_Image/_save/calls_the_class_method.yml +42 -39
- data/spec/vcr/Docker_Image/_save/when_a_filename_is_specified/exports_tarball_of_image_to_specified_file.yml +51 -63
- data/spec/vcr/Docker_Image/_save/when_no_filename_is_specified/returns_raw_binary_data_as_string.yml +51 -63
- data/spec/vcr/Docker_Image/_search/materializes_each_Image_into_a_Docker_Image.yml +48 -209
- data/spec/vcr/Docker_Image/_tag/tags_the_image_with_the_repo_name.yml +22 -22
- metadata +8 -8
- data/spec/vcr/Docker_Container/_exec/when_passed_only_a_command/returns_the_stdout/stderr_messages.yml +0 -153
- data/spec/vcr/Docker_Exec/_resize/when_exec_instance_has_TTY_enabled/returns_a_200.yml +0 -155
- data/spec/vcr/Docker_Exec/_start_/when_detach_is_set_to_true/returns_empty_stdout_and_stderr_messages.yml +0 -151
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f014fbf8eec822892584240bab7d8afa3ba9005e
|
4
|
+
data.tar.gz: 904edd7019308e5c17cdfb326d1ef49fc9a161b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a25da3ac701b0dc000b4e04b694b04c82fc25f7f18be51202eb94e379eee8c17c5e948089e7ef6dd5e656a279df94eb27d9b9c6b6dd70837a77e5a8be9fc3c0
|
7
|
+
data.tar.gz: eb715f87b92d6acbcde4522463ba0a07f18b1f464fd1c8d75937240054911191dd515ab291544439e2081c1ccaa35a7b76c82b4c9fb5da8aa1ec5167e8a8f359
|
data/README.md
CHANGED
@@ -333,31 +333,31 @@ container.commit
|
|
333
333
|
container.run('pwd', 10)
|
334
334
|
# => Docker::Image { :id => 4427be4199ac, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
|
335
335
|
|
336
|
-
# Run an Exec instance inside the container and capture its output
|
336
|
+
# Run an Exec instance inside the container and capture its output and exit status
|
337
337
|
container.exec('date')
|
338
|
-
# => [["Wed Nov 26 11:10:30 CST 2014\n"], []]
|
338
|
+
# => [["Wed Nov 26 11:10:30 CST 2014\n"], [], 0]
|
339
339
|
|
340
|
-
# Launch an Exec instance without capturing its output
|
340
|
+
# Launch an Exec instance without capturing its output or status
|
341
341
|
container.exec('./my_service', detach: true)
|
342
342
|
# => Docker::Exec { :id => be4eaeb8d28a, :connection => Docker::Connection { :url => tcp://localhost, :options => {:port=>2375} } }
|
343
343
|
|
344
344
|
# Parse the output of an Exec instance
|
345
345
|
container.exec('find / -name *') { |stream, chunk| puts "#{stream}: #{chunk}" }
|
346
346
|
stderr: 2013/10/30 17:16:24 Unable to locate find / -name *
|
347
|
-
# => [[], ["2013/10/30 17:16:24 Unable to locate find / -name *\n"]]
|
347
|
+
# => [[], ["2013/10/30 17:16:24 Unable to locate find / -name *\n"], 1]
|
348
348
|
|
349
349
|
# Run an Exec instance by grab only the STDOUT output
|
350
350
|
container.exec('date', stderr: false)
|
351
|
-
# => [["Wed Nov 26 11:10:30 CST 2014\n"], []]
|
351
|
+
# => [["Wed Nov 26 11:10:30 CST 2014\n"], [], 0]
|
352
352
|
|
353
353
|
# Pass input to an Exec instance command via Stdin
|
354
354
|
container.exec('cat', stdin: StringIO.new("foo\nbar\n"))
|
355
|
-
# => [["foo\nbar\n"], []]
|
355
|
+
# => [["foo\nbar\n"], [], 0]
|
356
356
|
|
357
357
|
# Get the raw stream of data from an Exec instance
|
358
358
|
command = ["bash", "-c", "if [ -t 1 ]; then echo -n \"I'm a TTY!\"; fi"]
|
359
359
|
container.exec(command, tty: true)
|
360
|
-
# => [["I'm a TTY!"], []]
|
360
|
+
# => [["I'm a TTY!"], [], 0]
|
361
361
|
|
362
362
|
# Delete a Container.
|
363
363
|
container.delete(:force => true)
|
data/lib/docker/exec.rb
CHANGED
@@ -25,6 +25,12 @@ class Docker::Exec
|
|
25
25
|
new(conn, hash)
|
26
26
|
end
|
27
27
|
|
28
|
+
# Get info about the Exec instance
|
29
|
+
#
|
30
|
+
def json
|
31
|
+
Docker::Util.parse_json(connection.get(path_for(:json), {}))
|
32
|
+
end
|
33
|
+
|
28
34
|
# Start the Exec instance. The Exec instance is deleted after this so this
|
29
35
|
# command can only be run once.
|
30
36
|
#
|
@@ -35,7 +41,7 @@ class Docker::Exec
|
|
35
41
|
# @option options [TrueClass, FalseClass] :tty (false) Whether to attach using
|
36
42
|
# a pseudo-TTY.
|
37
43
|
#
|
38
|
-
# @return [Array, Array] The STDOUT and
|
44
|
+
# @return [Array, Array, Int] The STDOUT, STDERR and exit code
|
39
45
|
def start!(options = {}, &block)
|
40
46
|
|
41
47
|
# Parse the Options
|
@@ -62,7 +68,7 @@ class Docker::Exec
|
|
62
68
|
end
|
63
69
|
|
64
70
|
connection.post(path_for(:start), nil, excon_params)
|
65
|
-
[msgs.stdout_messages, msgs.stderr_messages]
|
71
|
+
[msgs.stdout_messages, msgs.stderr_messages, self.json['ExitCode']]
|
66
72
|
end
|
67
73
|
|
68
74
|
# #start! performs the associated action and returns the output.
|
data/lib/docker/util.rb
CHANGED
@@ -61,7 +61,7 @@ module Docker::Util
|
|
61
61
|
IO.copy_stream stdin, socket
|
62
62
|
|
63
63
|
debug "hijack: closing write end of hijacked socket"
|
64
|
-
socket
|
64
|
+
close_write(socket)
|
65
65
|
end
|
66
66
|
|
67
67
|
debug "hijack: starting hijacked socket read thread"
|
@@ -84,6 +84,16 @@ module Docker::Util
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
def close_write(socket)
|
88
|
+
if socket.respond_to?(:close_write)
|
89
|
+
socket.close_write
|
90
|
+
elsif socket.respond_to?(:io)
|
91
|
+
socket.io.close_write
|
92
|
+
else
|
93
|
+
raise IOError, 'Cannot close socket'
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
87
97
|
def parse_json(body)
|
88
98
|
JSON.parse(body) unless body.nil? || body.empty? || (body == 'null')
|
89
99
|
rescue JSON::ParserError => ex
|
data/lib/docker/version.rb
CHANGED
@@ -296,8 +296,8 @@ describe Docker::Container do
|
|
296
296
|
context 'when passed only a command' do
|
297
297
|
let(:output) { subject.exec(['bash','-c','sleep 2; echo hello']) }
|
298
298
|
|
299
|
-
it 'returns the stdout/stderr messages', :vcr do
|
300
|
-
expect(output).to eq([["hello\n"], []])
|
299
|
+
it 'returns the stdout/stderr messages and exit code', :vcr do
|
300
|
+
expect(output).to eq([["hello\n"], [], 0])
|
301
301
|
end
|
302
302
|
end
|
303
303
|
|
@@ -325,7 +325,7 @@ describe Docker::Container do
|
|
325
325
|
|
326
326
|
it 'returns the stdout/stderr messages', :vcr do
|
327
327
|
skip 'HTTP socket hijacking not compatible with VCR'
|
328
|
-
expect(output).to eq([["hello"],[]])
|
328
|
+
expect(output).to eq([["hello"],[],0])
|
329
329
|
end
|
330
330
|
end
|
331
331
|
|
@@ -337,7 +337,7 @@ describe Docker::Container do
|
|
337
337
|
let(:output) { subject.exec(command, tty: true) }
|
338
338
|
|
339
339
|
it 'returns the raw stdout/stderr output', :vcr do
|
340
|
-
expect(output).to eq([["I'm a TTY!"], []])
|
340
|
+
expect(output).to eq([["I'm a TTY!"], [], 0])
|
341
341
|
end
|
342
342
|
end
|
343
343
|
end
|
@@ -534,13 +534,14 @@ describe Docker::Container do
|
|
534
534
|
}
|
535
535
|
let(:image) { subject.commit }
|
536
536
|
|
537
|
-
before { subject.start }
|
538
537
|
after(:each) do
|
539
538
|
subject.remove
|
540
539
|
image.remove
|
541
540
|
end
|
542
541
|
|
543
542
|
it 'creates a new Image from the Container\'s changes', :vcr do
|
543
|
+
subject.tap(&:start).wait
|
544
|
+
|
544
545
|
expect(image).to be_a Docker::Image
|
545
546
|
expect(image.id).to_not be_nil
|
546
547
|
end
|
data/spec/docker/exec_spec.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Docker::Exec do
|
4
|
+
let(:container) {
|
5
|
+
Docker::Container.create(
|
6
|
+
'Cmd' => %w(sleep 300),
|
7
|
+
'Image' => 'debian:wheezy'
|
8
|
+
).start!
|
9
|
+
}
|
4
10
|
|
5
11
|
describe '#to_s' do
|
6
12
|
subject {
|
@@ -26,12 +32,6 @@ describe Docker::Exec do
|
|
26
32
|
subject { described_class }
|
27
33
|
|
28
34
|
context 'when the HTTP request returns a 201' do
|
29
|
-
let(:container) {
|
30
|
-
Docker::Container.create(
|
31
|
-
'Cmd' => %w[sleep 5],
|
32
|
-
'Image' => 'debian:wheezy'
|
33
|
-
).start!
|
34
|
-
}
|
35
35
|
let(:options) do
|
36
36
|
{
|
37
37
|
'AttachStdin' => false,
|
@@ -70,14 +70,26 @@ describe Docker::Exec do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
describe '#
|
74
|
-
|
75
|
-
|
76
|
-
'
|
77
|
-
'
|
78
|
-
|
73
|
+
describe '#json' do
|
74
|
+
subject {
|
75
|
+
described_class.create(
|
76
|
+
'Container' => container.id,
|
77
|
+
'Detach' => true,
|
78
|
+
'Cmd' => %w[true]
|
79
|
+
)
|
79
80
|
}
|
80
81
|
|
82
|
+
let(:description) { subject.json }
|
83
|
+
before { subject.start! }
|
84
|
+
after { container.kill!.remove }
|
85
|
+
|
86
|
+
it 'returns the description as a Hash', :vcr do
|
87
|
+
expect(description).to be_a Hash
|
88
|
+
expect(description['ID']).to start_with(subject.id)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#start!' do
|
81
93
|
context 'when the exec instance does not exist' do
|
82
94
|
subject do
|
83
95
|
described_class.send(:new, Docker.connection, 'id' => rand(10000).to_s)
|
@@ -100,16 +112,17 @@ describe Docker::Exec do
|
|
100
112
|
after { container.kill!.remove }
|
101
113
|
|
102
114
|
it 'returns the stdout and stderr messages', :vcr do
|
103
|
-
expect(subject.start!).to eq([["hello\n"],[]])
|
115
|
+
expect(subject.start!).to eq([["hello\n"],[],0])
|
104
116
|
end
|
105
117
|
|
106
118
|
context 'block is passed' do
|
107
119
|
it 'attaches to the stream', :vcr do
|
108
120
|
chunk = nil
|
109
|
-
subject.start! do |stream, c|
|
121
|
+
result = subject.start! do |stream, c|
|
110
122
|
chunk ||= c
|
111
123
|
end
|
112
124
|
expect(chunk).to eq("hello\n")
|
125
|
+
expect(result).to eq([["hello\n"], [], 0])
|
113
126
|
end
|
114
127
|
end
|
115
128
|
end
|
@@ -120,8 +133,8 @@ describe Docker::Exec do
|
|
120
133
|
}
|
121
134
|
after { container.kill!.remove }
|
122
135
|
|
123
|
-
it 'returns empty stdout
|
124
|
-
expect(subject.start!(:detach => true)).to eq([[],[]])
|
136
|
+
it 'returns empty stdout/stderr messages with exitcode', :vcr do
|
137
|
+
expect(subject.start!(:detach => true)).to eq([[],[], 0])
|
125
138
|
end
|
126
139
|
end
|
127
140
|
|
@@ -149,49 +162,4 @@ describe Docker::Exec do
|
|
149
162
|
end
|
150
163
|
end
|
151
164
|
end
|
152
|
-
|
153
|
-
describe '#resize' do
|
154
|
-
let(:container) {
|
155
|
-
Docker::Container.create(
|
156
|
-
'Cmd' => %w[sleep 20],
|
157
|
-
'Image' => 'debian:wheezy'
|
158
|
-
).start!
|
159
|
-
}
|
160
|
-
|
161
|
-
context 'when exec instance has TTY enabled' do
|
162
|
-
let(:instance) do
|
163
|
-
described_class.create(
|
164
|
-
'Container' => container.id,
|
165
|
-
'AttachStdin' => true,
|
166
|
-
'Tty' => true,
|
167
|
-
'Cmd' => %w[/bin/bash]
|
168
|
-
)
|
169
|
-
end
|
170
|
-
after do
|
171
|
-
container.kill!
|
172
|
-
sleep 1
|
173
|
-
container.remove
|
174
|
-
end
|
175
|
-
|
176
|
-
it 'returns a 200', :vcr do
|
177
|
-
t = Thread.new do
|
178
|
-
instance.start!(:tty => true)
|
179
|
-
end
|
180
|
-
sleep 1
|
181
|
-
expect { instance.resize(:h => 10, :w => 30) }.not_to raise_error
|
182
|
-
t.kill
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
context 'when the exec instance does not exist' do
|
187
|
-
subject do
|
188
|
-
described_class.send(:new, Docker.connection, 'id' => rand(10000).to_s)
|
189
|
-
end
|
190
|
-
|
191
|
-
it 'raises an error', :vcr do
|
192
|
-
skip 'The Docker API returns a 200 (docker/docker#9341)'
|
193
|
-
expect { subject.resize }.to raise_error(Docker::Error::NotFoundError)
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
165
|
end
|
data/spec/docker/image_spec.rb
CHANGED
@@ -221,9 +221,10 @@ describe Docker::Image do
|
|
221
221
|
|
222
222
|
context 'when the argument is a String', :vcr do
|
223
223
|
let(:cmd) { 'ls /lib64/' }
|
224
|
-
after { container.
|
224
|
+
after { container.remove }
|
225
225
|
|
226
226
|
it 'splits the String by spaces and creates a new Container' do
|
227
|
+
container.wait
|
227
228
|
expect(output).to eq("ld-linux-x86-64.so.2\n")
|
228
229
|
end
|
229
230
|
end
|
@@ -249,9 +250,10 @@ describe Docker::Image do
|
|
249
250
|
|
250
251
|
context "command configured in image" do
|
251
252
|
let(:cmd) { 'pwd' }
|
252
|
-
after { container.
|
253
|
+
after { container.remove }
|
253
254
|
|
254
255
|
it 'should normally show result if image has Cmd configured' do
|
256
|
+
container.wait
|
255
257
|
expect(output).to eql "/\n"
|
256
258
|
end
|
257
259
|
end
|
@@ -562,8 +564,9 @@ describe Docker::Image do
|
|
562
564
|
Docker::Container.create('Image' => image.id,
|
563
565
|
'Cmd' => %w[cat /Dockerfile])
|
564
566
|
end
|
565
|
-
let(:output) {
|
566
|
-
|
567
|
+
let!(:output) {
|
568
|
+
container.tap(&:start).streaming_logs(stdout: true)
|
569
|
+
}
|
567
570
|
after(:each) do
|
568
571
|
container.tap(&:wait).remove
|
569
572
|
image.remove(:noprune => true)
|
@@ -571,6 +574,7 @@ describe Docker::Image do
|
|
571
574
|
|
572
575
|
context 'with no query parameters' do
|
573
576
|
it 'builds the image', :vcr do
|
577
|
+
container.wait
|
574
578
|
expect(output).to eq(docker_file.read)
|
575
579
|
end
|
576
580
|
end
|
data/spec/docker_spec.rb
CHANGED
@@ -145,9 +145,10 @@ describe Docker do
|
|
145
145
|
|
146
146
|
let(:info) { subject.info }
|
147
147
|
let(:keys) do
|
148
|
-
%w(Containers Debug Driver DriverStatus ExecutionDriver
|
149
|
-
Images IndexServerAddress InitPath InitSha1
|
150
|
-
|
148
|
+
%w(Containers Debug DockerRootDir Driver DriverStatus ExecutionDriver ID
|
149
|
+
IPv4Forwarding Images IndexServerAddress InitPath InitSha1
|
150
|
+
KernelVersion Labels MemTotal MemoryLimit NCPU NEventsListener NFd
|
151
|
+
NGoroutines Name OperatingSystem SwapLimit)
|
151
152
|
end
|
152
153
|
|
153
154
|
it 'returns the info as a Hash', :vcr do
|
@@ -1,2 +1,2 @@
|
|
1
1
|
FROM debian:wheezy
|
2
|
-
ADD
|
2
|
+
ADD . /
|
@@ -2,13 +2,13 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: post
|
5
|
-
uri:
|
5
|
+
uri: <DOCKER_HOST>/v1.16/auth
|
6
6
|
body:
|
7
7
|
encoding: UTF-8
|
8
|
-
string: '{"username":"<USERNAME>","password":"<PASSWORD>","email":"<
|
8
|
+
string: ! '{"username":"<USERNAME>","password":"<PASSWORD>","email":"<USERNAME>@gmail.com","serveraddress":"https://index.docker.io/v1/"}'
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Swipely/Docker-API 1.
|
11
|
+
- Swipely/Docker-API 1.18.0
|
12
12
|
Content-Type:
|
13
13
|
- application/json
|
14
14
|
response:
|
@@ -19,13 +19,14 @@ http_interactions:
|
|
19
19
|
Content-Type:
|
20
20
|
- application/json
|
21
21
|
Date:
|
22
|
-
-
|
22
|
+
- Thu, 12 Feb 2015 00:56:24 GMT
|
23
23
|
Content-Length:
|
24
24
|
- '29'
|
25
25
|
body:
|
26
|
-
encoding:
|
27
|
-
string:
|
28
|
-
|
26
|
+
encoding: US-ASCII
|
27
|
+
string: ! '{"Status":"Login Succeeded"}
|
28
|
+
|
29
|
+
'
|
29
30
|
http_version:
|
30
|
-
recorded_at:
|
31
|
-
recorded_with: VCR 2.9.
|
31
|
+
recorded_at: Thu, 12 Feb 2015 00:56:24 GMT
|
32
|
+
recorded_with: VCR 2.9.2
|
@@ -2,13 +2,13 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri:
|
5
|
+
uri: <DOCKER_HOST>/v1.16/info
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
9
9
|
headers:
|
10
10
|
User-Agent:
|
11
|
-
- Swipely/Docker-API 1.
|
11
|
+
- Swipely/Docker-API 1.18.0
|
12
12
|
Content-Type:
|
13
13
|
- text/plain
|
14
14
|
response:
|
@@ -21,13 +21,19 @@ http_interactions:
|
|
21
21
|
Job-Name:
|
22
22
|
- info
|
23
23
|
Date:
|
24
|
-
-
|
24
|
+
- Thu, 12 Feb 2015 00:56:23 GMT
|
25
25
|
Content-Length:
|
26
|
-
- '
|
26
|
+
- '957'
|
27
27
|
body:
|
28
|
-
encoding:
|
29
|
-
string:
|
30
|
-
|
28
|
+
encoding: US-ASCII
|
29
|
+
string: ! '{"Containers":2,"Debug":1,"DockerRootDir":"/var/lib/docker","Driver":"devicemapper","DriverStatus":[["Pool
|
30
|
+
Name","docker-8:1-1049879-pool"],["Pool Blocksize","65.54 kB"],["Data file","/var/lib/docker/devicemapper/devicemapper/data"],["Metadata
|
31
|
+
file","/var/lib/docker/devicemapper/devicemapper/metadata"],["Data Space Used","955.4
|
32
|
+
MB"],["Data Space Total","107.4 GB"],["Metadata Space Used","1.933 MB"],["Metadata
|
33
|
+
Space Total","2.147 GB"],["Library Version","1.02.92 (2014-11-28)"]],"ExecutionDriver":"native-0.2","ID":"6WA4:W5WW:QDFQ:BD5S:L2MJ:KXLK:UUYQ:AQ3U:4V62:XISI:YHFH:HUYG","IPv4Forwarding":1,"Images":27,"IndexServerAddress":"https://index.docker.io/v1/","InitPath":"/usr/lib/docker/dockerinit","InitSha1":"7f82b25cad873786f2c2d72d9ceecc1d46e0a65b","KernelVersion":"3.17.6-1-ARCH","Labels":null,"MemTotal":6255366144,"MemoryLimit":1,"NCPU":1,"NEventsListener":0,"NFd":19,"NGoroutines":45,"Name":"docker","OperatingSystem":"Arch
|
34
|
+
Linux","SwapLimit":0}
|
35
|
+
|
36
|
+
'
|
31
37
|
http_version:
|
32
|
-
recorded_at:
|
33
|
-
recorded_with: VCR 2.9.
|
38
|
+
recorded_at: Thu, 12 Feb 2015 00:56:23 GMT
|
39
|
+
recorded_with: VCR 2.9.2
|