vocker 0.3.3 → 0.4.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/CHANGELOG.md +15 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +51 -29
- data/README.md +25 -6
- data/development/Vagrantfile +18 -2
- data/lib/vocker/cap/debian/docker_configure_vagrant_user.rb +1 -2
- data/lib/vocker/cap/debian/docker_install.rb +6 -2
- data/lib/vocker/cap/linux/docker_installed.rb +1 -1
- data/lib/vocker/config.rb +3 -0
- data/lib/vocker/docker_client.rb +31 -4
- data/lib/vocker/docker_installer.rb +3 -2
- data/lib/vocker/provisioner.rb +1 -1
- data/lib/vocker/version.rb +1 -1
- data/spec/unit/docker_client_spec.rb +72 -23
- data/spec/unit/docker_installer_spec.rb +3 -2
- 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: c785f4c29b6d9c5582b89d6ced1f5650c48e6818
|
4
|
+
data.tar.gz: dfca0bc2e02c1d62ee815e7c991cffed85167137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f4e352b6ac9f5451c6e6ba22e95bcb4aa1b61783d1ed881b78fd6cffedc981df4d8e8d4c8badf4963cea19ba95161f15cd9ac04e74ec4d4f477cfe1f2ecf6e3
|
7
|
+
data.tar.gz: e647a3667479df5d40b9f3729a668066e9308bba9554f16a0f06b680abed7a0d293aebb601e5d71c50a4f7407a72542e7b251239d16b16ef78e48695119cb9d5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## [0.4.0](https://github.com/fgrehm/vocker/compare/v0.3.3...v0.4.0) (November 8, 2013)
|
2
|
+
|
3
|
+
IMPROVEMENTS:
|
4
|
+
|
5
|
+
- Make use of configured SSH user when adding to `docker` group [GH-17]
|
6
|
+
- Support for data volumes [GH-13]
|
7
|
+
- Support for exposing ports [GH-10]
|
8
|
+
- Support for naming containers [GH-11]
|
9
|
+
- Support for installing a specific Docker version [GH-9]
|
10
|
+
- Improved checking for whether Docker is installed
|
11
|
+
|
12
|
+
BUG FIXES:
|
13
|
+
|
14
|
+
- Make sure `curl` is installed on guest VMs [GH-15]
|
15
|
+
|
1
16
|
## [0.3.3](https://github.com/fgrehm/vocker/compare/v0.3.2...v0.3.3) (October 15, 2013)
|
2
17
|
|
3
18
|
- Prevent `-r=true` from being appended multiple times to `/etc/init/docker.conf`
|
data/Gemfile
CHANGED
@@ -5,10 +5,10 @@ gemspec
|
|
5
5
|
|
6
6
|
group :development do
|
7
7
|
gem 'vagrant', github: 'mitchellh/vagrant'
|
8
|
-
gem 'vagrant-lxc'
|
9
|
-
gem 'vagrant-cachier'
|
10
|
-
gem 'vagrant-pristine'
|
11
|
-
gem 'vagrant-global-status'
|
8
|
+
gem 'vagrant-lxc', github:'fgrehm/vagrant-lxc'
|
9
|
+
gem 'vagrant-cachier', github:'fgrehm/vagrant-cachier', branch: 'release-0.5.0'
|
10
|
+
gem 'vagrant-pristine', github:'fgrehm/vagrant-pristine'
|
11
|
+
gem 'vagrant-global-status', github: 'fgrehm/vagrant-global-status'
|
12
12
|
|
13
13
|
gem 'rspec'
|
14
14
|
gem 'simplecov', require: false
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,33 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/fgrehm/vagrant-cachier.git
|
3
|
+
revision: 4d01bff390f036bf76b74f96a3f569e8308cf7b0
|
4
|
+
branch: release-0.5.0
|
5
|
+
specs:
|
6
|
+
vagrant-cachier (0.5.0)
|
7
|
+
|
8
|
+
GIT
|
9
|
+
remote: git://github.com/fgrehm/vagrant-global-status.git
|
10
|
+
revision: a0295400a0e47756cbcb8f97ed9f4449b1fb6b56
|
11
|
+
specs:
|
12
|
+
vagrant-global-status (0.1.1)
|
13
|
+
|
14
|
+
GIT
|
15
|
+
remote: git://github.com/fgrehm/vagrant-lxc.git
|
16
|
+
revision: 3d017ce3bdc46605c01605cd427893d61293fab1
|
17
|
+
specs:
|
18
|
+
vagrant-lxc (0.7.0.dev)
|
19
|
+
|
20
|
+
GIT
|
21
|
+
remote: git://github.com/fgrehm/vagrant-pristine.git
|
22
|
+
revision: 4638491786943bfbf6f115b1fc379f069963fe46
|
23
|
+
specs:
|
24
|
+
vagrant-pristine (0.3.0)
|
25
|
+
|
1
26
|
GIT
|
2
27
|
remote: git://github.com/mitchellh/vagrant.git
|
3
|
-
revision:
|
28
|
+
revision: a92e03cf4ce936243d3959b7b5603262a234a58d
|
4
29
|
specs:
|
5
|
-
vagrant (1.3.
|
30
|
+
vagrant (1.3.6.dev)
|
6
31
|
childprocess (~> 0.3.7)
|
7
32
|
erubis (~> 2.7.0)
|
8
33
|
i18n (~> 0.6.0)
|
@@ -13,39 +38,41 @@ GIT
|
|
13
38
|
PATH
|
14
39
|
remote: .
|
15
40
|
specs:
|
16
|
-
vocker (0.
|
41
|
+
vocker (0.4.0)
|
17
42
|
|
18
43
|
GEM
|
19
44
|
remote: https://rubygems.org/
|
20
45
|
specs:
|
21
46
|
bogus (0.1.4)
|
22
47
|
dependor (>= 0.0.4)
|
48
|
+
celluloid (0.15.2)
|
49
|
+
timers (~> 1.1.0)
|
23
50
|
childprocess (0.3.9)
|
24
51
|
ffi (~> 1.0, >= 1.0.11)
|
25
52
|
coderay (1.0.9)
|
26
53
|
dependor (1.0.1)
|
27
54
|
diff-lcs (1.2.4)
|
28
55
|
erubis (2.7.0)
|
29
|
-
ffi (1.9.
|
56
|
+
ffi (1.9.3)
|
30
57
|
formatador (0.2.4)
|
31
|
-
guard (
|
58
|
+
guard (2.2.3)
|
32
59
|
formatador (>= 0.2.4)
|
33
|
-
listen (
|
34
|
-
lumberjack (
|
35
|
-
pry (>= 0.9.
|
36
|
-
thor (>= 0.
|
37
|
-
guard-rspec (
|
38
|
-
guard (>= 1.
|
39
|
-
rspec (~> 2.
|
60
|
+
listen (~> 2.1)
|
61
|
+
lumberjack (~> 1.0)
|
62
|
+
pry (>= 0.9.12)
|
63
|
+
thor (>= 0.18.1)
|
64
|
+
guard-rspec (4.0.3)
|
65
|
+
guard (>= 2.1.1)
|
66
|
+
rspec (~> 2.14)
|
40
67
|
i18n (0.6.5)
|
41
|
-
listen (
|
68
|
+
listen (2.2.0)
|
69
|
+
celluloid (>= 0.15.2)
|
42
70
|
rb-fsevent (>= 0.9.3)
|
43
71
|
rb-inotify (>= 0.9)
|
44
|
-
rb-kqueue (>= 0.2)
|
45
72
|
log4r (1.1.10)
|
46
73
|
lumberjack (1.0.4)
|
47
74
|
method_source (0.8.2)
|
48
|
-
multi_json (1.
|
75
|
+
multi_json (1.8.2)
|
49
76
|
net-scp (1.1.2)
|
50
77
|
net-ssh (>= 2.6.5)
|
51
78
|
net-ssh (2.6.8)
|
@@ -55,28 +82,23 @@ GEM
|
|
55
82
|
slop (~> 3.4)
|
56
83
|
rake (10.1.0)
|
57
84
|
rb-fsevent (0.9.3)
|
58
|
-
rb-inotify (0.9.
|
59
|
-
ffi (>= 0.5.0)
|
60
|
-
rb-kqueue (0.2.0)
|
85
|
+
rb-inotify (0.9.2)
|
61
86
|
ffi (>= 0.5.0)
|
62
87
|
rspec (2.14.1)
|
63
88
|
rspec-core (~> 2.14.0)
|
64
89
|
rspec-expectations (~> 2.14.0)
|
65
90
|
rspec-mocks (~> 2.14.0)
|
66
|
-
rspec-core (2.14.
|
67
|
-
rspec-expectations (2.14.
|
91
|
+
rspec-core (2.14.7)
|
92
|
+
rspec-expectations (2.14.4)
|
68
93
|
diff-lcs (>= 1.1.3, < 2.0)
|
69
|
-
rspec-mocks (2.14.
|
94
|
+
rspec-mocks (2.14.4)
|
70
95
|
simplecov (0.7.1)
|
71
96
|
multi_json (~> 1.0)
|
72
97
|
simplecov-html (~> 0.7.1)
|
73
98
|
simplecov-html (0.7.1)
|
74
99
|
slop (3.4.6)
|
75
100
|
thor (0.18.1)
|
76
|
-
|
77
|
-
vagrant-global-status (0.1.1)
|
78
|
-
vagrant-lxc (0.6.3)
|
79
|
-
vagrant-pristine (0.2.0)
|
101
|
+
timers (1.1.0)
|
80
102
|
|
81
103
|
PLATFORMS
|
82
104
|
ruby
|
@@ -89,8 +111,8 @@ DEPENDENCIES
|
|
89
111
|
rspec
|
90
112
|
simplecov
|
91
113
|
vagrant!
|
92
|
-
vagrant-cachier
|
93
|
-
vagrant-global-status
|
94
|
-
vagrant-lxc
|
95
|
-
vagrant-pristine
|
114
|
+
vagrant-cachier!
|
115
|
+
vagrant-global-status!
|
116
|
+
vagrant-lxc!
|
117
|
+
vagrant-pristine!
|
96
118
|
vocker!
|
data/README.md
CHANGED
@@ -65,6 +65,10 @@ containers to run:
|
|
65
65
|
```ruby
|
66
66
|
Vagrant.configure("2") do |config|
|
67
67
|
config.vm.provision :docker do |docker|
|
68
|
+
# Things are changing pretty fast, you might want to lock the Docker
|
69
|
+
# version on the guest VM.
|
70
|
+
docker.version = '0.6.3' # default -> :latest
|
71
|
+
|
68
72
|
# If you just want to pull in some base images
|
69
73
|
docker.pull_images 'ubuntu', 'busybox'
|
70
74
|
|
@@ -72,16 +76,28 @@ Vagrant.configure("2") do |config|
|
|
72
76
|
docker.run 'echo ls -la --color', 'ubuntu'
|
73
77
|
|
74
78
|
# Unique container name + other configs
|
75
|
-
docker.run '
|
79
|
+
docker.run 'app-1',
|
80
|
+
image: 'user/app',
|
81
|
+
ports: ['8080:80', '80', ':80'],
|
82
|
+
links: ['mysql:db'],
|
83
|
+
# Vocker will automagically create /var/lib/docker/mysql on the
|
84
|
+
# guest VM if it doesn't exist
|
85
|
+
volumes: ['/var/lib/docker/app:/var/lib/app'],
|
86
|
+
cmd: '/usr/bin/run-app'
|
76
87
|
|
77
88
|
# Base image (requires ENTRYPOINT / CMD) to be configured:
|
78
89
|
# * http://docs.docker.io/en/latest/use/builder/#entrypoint
|
79
90
|
# * http://docs.docker.io/en/latest/use/builder/#cmd
|
80
91
|
docker.run 'user/mysql'
|
81
92
|
|
82
|
-
# If you need to
|
83
|
-
#
|
84
|
-
docker
|
93
|
+
# If you need to use some random / new parameter you can pass in additional
|
94
|
+
# arguments as wanted. The example below is the same as:
|
95
|
+
# docker run -v /host:/container -p 1234:3306 -d user/patched-mysql /usr/bin/mysql
|
96
|
+
docker.run mysql: {
|
97
|
+
additional_run_args: '-v /host:/container -p 1234:3306',
|
98
|
+
image: 'user/patched-mysql',
|
99
|
+
cmd: '/usr/bin/mysql'
|
100
|
+
}
|
85
101
|
end
|
86
102
|
end
|
87
103
|
```
|
@@ -112,8 +128,9 @@ pull, push, restart, rm, rmi, run, search, start, stop, tag, version, wait
|
|
112
128
|
|
113
129
|
In case you want to build a Vagrant plugin that needs to interact with Docker you
|
114
130
|
can add this plugin as a dependency and use [DockerClient](lib/vocker/docker_client.rb)
|
115
|
-
/ [DockerInstaller](lib/vocker/docker_installer.rb) classes.
|
116
|
-
|
131
|
+
/ [DockerInstaller](lib/vocker/docker_installer.rb) classes. As an example you can
|
132
|
+
check out [Ventriloquist](https://github.com/fgrehm/ventriloquist) that builds on top
|
133
|
+
of this plugin.
|
117
134
|
|
118
135
|
|
119
136
|
### Usage with [vagrant-lxc](https://github.com/fgrehm/vagrant-lxc)
|
@@ -164,3 +181,5 @@ will collide with the host's `lxcbr0`.
|
|
164
181
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
165
182
|
4. Push to the branch (`git push origin my-new-feature`)
|
166
183
|
5. Create new Pull Request
|
184
|
+
|
185
|
+
[](https://bitdeli.com/free "Bitdeli Badge")
|
data/development/Vagrantfile
CHANGED
@@ -31,7 +31,7 @@ STR
|
|
31
31
|
|
32
32
|
config.vm.define :vm1 do |vm1|
|
33
33
|
vm1.vm.provision :docker do |docker|
|
34
|
-
docker.pull_images '
|
34
|
+
docker.pull_images 'busybox'
|
35
35
|
docker.run 'echo ls -la --color', 'busybox'
|
36
36
|
docker.run 'echo ls -la --color', image: 'busybox' # Above is the default
|
37
37
|
docker.run 'date', additional_run_args: '-p 1234:562', image: 'busybox', cmd: '/bin/sh -c "while true; date; do echo hello world; sleep 1; done"'
|
@@ -39,6 +39,22 @@ STR
|
|
39
39
|
end
|
40
40
|
|
41
41
|
config.vm.define :vm2 do |vm2|
|
42
|
-
|
42
|
+
# TODO: Clean up these examples
|
43
|
+
vm2.vm.provision :docker do |docker|
|
44
|
+
docker.version = '0.6.5'
|
45
|
+
|
46
|
+
hello_daemon = 'while true; do date; date > /tmp/testing/dates.log; date +%s > /var/lib/other/seconds; echo hello world; sleep 1; done'
|
47
|
+
docker.run 'date',
|
48
|
+
image: 'busybox',
|
49
|
+
volumes: ['/tmp/testing:/tmp/testing', '/var/lib/other'],
|
50
|
+
ports: ['8080/udp', '8081:80'],
|
51
|
+
cmd: "/bin/sh -c '#{hello_daemon}'"
|
52
|
+
|
53
|
+
hello_daemon = 'while true; do date; echo hello world; sleep 1; done'
|
54
|
+
docker.run 'date-2',
|
55
|
+
image: 'busybox',
|
56
|
+
link: ['date:datetime'],
|
57
|
+
cmd: "/bin/sh -c '#{hello_daemon}'"
|
58
|
+
end
|
43
59
|
end
|
44
60
|
end
|
@@ -4,8 +4,7 @@ module VagrantPlugins
|
|
4
4
|
module Debian
|
5
5
|
module DockerConfigureVagrantUser
|
6
6
|
def self.docker_configure_vagrant_user(machine)
|
7
|
-
|
8
|
-
machine.communicate.sudo("usermod -a -G docker vagrant")
|
7
|
+
machine.communicate.sudo("usermod -a -G docker #{machine.config.ssh.username || "vagrant"}")
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
@@ -3,16 +3,20 @@ module VagrantPlugins
|
|
3
3
|
module Cap
|
4
4
|
module Debian
|
5
5
|
module DockerInstall
|
6
|
-
def self.docker_install(machine)
|
6
|
+
def self.docker_install(machine, version)
|
7
|
+
package = 'lxc-docker'
|
8
|
+
package << "-#{version}" if version != :latest
|
9
|
+
|
7
10
|
machine.communicate.tap do |comm|
|
8
11
|
# TODO: Perform check on the host machine if aufs is installed and using LXC
|
9
12
|
if machine.provider_name != :lxc
|
10
13
|
comm.sudo("lsmod | grep aufs || modprobe aufs || apt-get install -y linux-image-extra-`uname -r`")
|
11
14
|
end
|
15
|
+
comm.sudo("apt-get install -y --force-yes -q curl")
|
12
16
|
comm.sudo("curl http://get.docker.io/gpg | apt-key add -")
|
13
17
|
comm.sudo("echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list")
|
14
18
|
comm.sudo("apt-get update")
|
15
|
-
comm.sudo("apt-get install -y -q xz-utils
|
19
|
+
comm.sudo("apt-get install -y --force-yes -q xz-utils #{package} -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'")
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
data/lib/vocker/config.rb
CHANGED
@@ -4,10 +4,12 @@ module VagrantPlugins
|
|
4
4
|
module Vocker
|
5
5
|
class Config < Vagrant.plugin("2", :config)
|
6
6
|
attr_reader :images, :containers
|
7
|
+
attr_accessor :version
|
7
8
|
|
8
9
|
def initialize
|
9
10
|
@images = Set.new
|
10
11
|
@containers = Hash.new
|
12
|
+
@version = :latest
|
11
13
|
end
|
12
14
|
|
13
15
|
def pull_images(*images)
|
@@ -28,6 +30,7 @@ module VagrantPlugins
|
|
28
30
|
params[:cmd] ||= container_name
|
29
31
|
end
|
30
32
|
|
33
|
+
# TODO: Validate provided parameters before assignment
|
31
34
|
@containers[container_name.to_s] = params
|
32
35
|
end
|
33
36
|
|
data/lib/vocker/docker_client.rb
CHANGED
@@ -31,7 +31,7 @@ module VagrantPlugins
|
|
31
31
|
config[:cidfile] ||= "#{cids_dir}/#{Digest::SHA1.hexdigest name}"
|
32
32
|
|
33
33
|
@machine.communicate.sudo("mkdir -p #{cids_dir}")
|
34
|
-
run_container(config)
|
34
|
+
run_container({name: name}.merge config)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -62,14 +62,41 @@ module VagrantPlugins
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def create_container(config)
|
65
|
-
|
66
|
-
|
67
|
-
|
65
|
+
# DISCUSS: Does this really belong here?
|
66
|
+
ensure_bind_mounts_exist(config)
|
67
|
+
|
68
|
+
args = "-cidfile=#{config[:cidfile]} -d "
|
69
|
+
args << prepare_run_arguments(config)
|
68
70
|
@machine.communicate.sudo %[
|
69
71
|
rm -f #{config[:cidfile]}
|
70
72
|
docker run #{args} #{config[:image]} #{config[:cmd]}
|
71
73
|
]
|
72
74
|
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def ensure_bind_mounts_exist(config)
|
79
|
+
Array(config[:volumes]).each do |volume|
|
80
|
+
if volume =~ /(.+):.+/
|
81
|
+
guest_vm_path = $1
|
82
|
+
@machine.communicate.sudo "mkdir -p #{guest_vm_path}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def prepare_run_arguments(config)
|
88
|
+
args = []
|
89
|
+
|
90
|
+
args << "-dns=#{config[:dns]}" if config[:dns]
|
91
|
+
args << "-name=#{config[:name]}" if config[:name]
|
92
|
+
args << "#{config[:additional_run_args]}" if config[:additional_run_args]
|
93
|
+
|
94
|
+
args += Array(config[:volumes]).map { |volume| "-v #{volume}" }
|
95
|
+
args += Array(config[:ports]).map { |port| "-p #{port}" }
|
96
|
+
args += Array(config[:links]).map { |link| "-link #{link}" }
|
97
|
+
|
98
|
+
args.compact.flatten.join ' '
|
99
|
+
end
|
73
100
|
end
|
74
101
|
end
|
75
102
|
end
|
@@ -3,8 +3,9 @@ require_relative "errors"
|
|
3
3
|
module VagrantPlugins
|
4
4
|
module Vocker
|
5
5
|
class DockerInstaller
|
6
|
-
def initialize(machine)
|
6
|
+
def initialize(machine, version)
|
7
7
|
@machine = machine
|
8
|
+
@version = version
|
8
9
|
end
|
9
10
|
|
10
11
|
# This handles verifying the Docker installation, installing it if it was
|
@@ -18,7 +19,7 @@ module VagrantPlugins
|
|
18
19
|
|
19
20
|
if !@machine.guest.capability(:docker_installed)
|
20
21
|
@machine.ui.info(I18n.t("vagrant.docker_installing"))
|
21
|
-
@machine.guest.capability(:docker_install)
|
22
|
+
@machine.guest.capability(:docker_install, @version)
|
22
23
|
|
23
24
|
if !@machine.guest.capability(:docker_installed)
|
24
25
|
raise Errors::DockerInstallFailed
|
data/lib/vocker/provisioner.rb
CHANGED
@@ -9,7 +9,7 @@ module VagrantPlugins
|
|
9
9
|
class Provisioner < Vagrant.plugin("2", :provisioner)
|
10
10
|
def initialize(machine, config, installer = nil, client = nil)
|
11
11
|
super(machine, config)
|
12
|
-
@installer = installer || DockerInstaller.new(@machine)
|
12
|
+
@installer = installer || DockerInstaller.new(@machine, config.version)
|
13
13
|
@client = client || DockerClient.new(@machine)
|
14
14
|
end
|
15
15
|
|
data/lib/vocker/version.rb
CHANGED
@@ -35,32 +35,58 @@ describe VagrantPlugins::Vocker::DockerClient do
|
|
35
35
|
expect(communicator).to have_received.sudo('mkdir -p /var/lib/vocker/cids')
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
context 'parameters' do
|
39
|
+
let(:containers) { {
|
40
|
+
'my-db' => {
|
41
|
+
image: 'mysql',
|
42
|
+
cidfile: '/foo/bla',
|
43
|
+
dns: '127.0.0.1',
|
44
|
+
volumes: ['/host/path:/guest/path', '/container-volume'],
|
45
|
+
ports: ['1:2', ':3'],
|
46
|
+
links: ['other:db', 'foo:bar'],
|
47
|
+
additional_run_args: 'some parameter'
|
48
|
+
}
|
49
|
+
} }
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-cidfile=\/foo\/bla/})
|
50
|
-
end
|
51
|
+
before do
|
52
|
+
stub(communicator).test(with{|cmd| cmd =~ /docker ps/}) { false }
|
53
|
+
subject.run containers
|
54
|
+
end
|
51
55
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
it 'automatically assigns a digest of the image name as the cidfile if not specified' do
|
57
|
+
stub(Digest::SHA1).hexdigest('my-db') { 'digest' }
|
58
|
+
containers['my-db'][:cidfile] = nil
|
59
|
+
subject.run containers
|
60
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-cidfile=\/var\/lib\/vocker\/cids\/digest/})
|
61
|
+
end
|
58
62
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
it 'allows cidfile to be specified' do
|
64
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-cidfile=\/foo\/bla/})
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'allows a dns to be specified' do
|
68
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-dns=127\.0\.0\.1/})
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'allows an array of ports to be specified' do
|
72
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-p 1:2 -p :3/})
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'allows an array of volumes to be specified' do
|
76
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-v \/host\/path:\/guest\/path -v \/container-volume/})
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'allows an array of links to be specified' do
|
80
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-link other:db -link foo:bar/})
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'provides the container name to the docker command' do
|
84
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-name=my-db/})
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'allows additional params to be passed to the run command' do
|
88
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /some parameter/})
|
89
|
+
end
|
64
90
|
end
|
65
91
|
|
66
92
|
context 'when the container already exists' do
|
@@ -91,5 +117,28 @@ describe VagrantPlugins::Vocker::DockerClient do
|
|
91
117
|
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /docker run/})
|
92
118
|
end
|
93
119
|
end
|
120
|
+
|
121
|
+
context 'bind mounts' do
|
122
|
+
before do
|
123
|
+
containers['mysql'][:volumes] = '/guest/path:/container/path'
|
124
|
+
stub(communicator).test(with{|cmd| cmd =~ /docker ps/}) { false }
|
125
|
+
subject.run containers
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'ensures the guest VM path exists' do
|
129
|
+
expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /mkdir -p \/guest\/path/})
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'data volumes' do
|
134
|
+
before do
|
135
|
+
containers['mysql'][:volumes] = ['/container/path']
|
136
|
+
subject.run containers
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'does not try to create a guest path it' do
|
140
|
+
expect(communicator).to_not have_received.sudo(with{|cmd| cmd =~ /mkdir -p \/container\/path/})
|
141
|
+
end
|
142
|
+
end
|
94
143
|
end
|
95
144
|
end
|
@@ -11,8 +11,9 @@ describe VagrantPlugins::Vocker::DockerInstaller do
|
|
11
11
|
fake(:guest)
|
12
12
|
fake(:ui) { Vagrant::UI::Interface }
|
13
13
|
let(:machine) { fake(:machine, guest: guest, ui: ui) }
|
14
|
+
let(:version) { '0.6.4' }
|
14
15
|
|
15
|
-
subject { described_class.new(machine) }
|
16
|
+
subject { described_class.new(machine, version) }
|
16
17
|
|
17
18
|
it 'skips docker installation if guest is not capable' do
|
18
19
|
stub(guest).capability?(:docker_installed) { false }
|
@@ -42,7 +43,7 @@ describe VagrantPlugins::Vocker::DockerInstaller do
|
|
42
43
|
subject.ensure_installed
|
43
44
|
|
44
45
|
expect(guest).to have_received.capability(:docker_installed)
|
45
|
-
expect(guest).to have_received.capability(:docker_install)
|
46
|
+
expect(guest).to have_received.capability(:docker_install, version)
|
46
47
|
expect(guest).to have_received.capability(:docker_configure_auto_start)
|
47
48
|
end
|
48
49
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabio Rehm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|