vocker 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67d9bfc4a2cc6dabde1fc13b5321f430caa7df86
4
- data.tar.gz: a201fa7d0a147ef2ba01fa6855823b225e0589a7
3
+ metadata.gz: c785f4c29b6d9c5582b89d6ced1f5650c48e6818
4
+ data.tar.gz: dfca0bc2e02c1d62ee815e7c991cffed85167137
5
5
  SHA512:
6
- metadata.gz: 4152325e8967bdf16fb499b48b109958e07bebe0fa0e481e1056c3e2c9be076574b41297480477f5c2d56ab7bf07d9d88bbe10dae2e30c96da081fb7b86a1ead
7
- data.tar.gz: 4c43b4ea5085d1e9e3b0515e5119bf31af8b74c615c4c5b6f2e53109567d685fbbdc5f927458f1364f23095a71d8b9e61d65065fbff7513d0ec402cf3c6d7e33
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: a06742b8ef40b983d949bc9492a5a2a432530323
28
+ revision: a92e03cf4ce936243d3959b7b5603262a234a58d
4
29
  specs:
5
- vagrant (1.3.1.dev)
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.3.3)
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.0)
56
+ ffi (1.9.3)
30
57
  formatador (0.2.4)
31
- guard (1.8.2)
58
+ guard (2.2.3)
32
59
  formatador (>= 0.2.4)
33
- listen (>= 1.0.0)
34
- lumberjack (>= 1.0.2)
35
- pry (>= 0.9.10)
36
- thor (>= 0.14.6)
37
- guard-rspec (3.0.2)
38
- guard (>= 1.8)
39
- rspec (~> 2.13)
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 (1.3.0)
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.7.9)
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.1)
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.5)
67
- rspec-expectations (2.14.2)
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.3)
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
- vagrant-cachier (0.3.2)
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 'date', image: 'ubuntu', cmd: '/bin/sh -c "while true; date; do echo hello world; sleep 1; done"'
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 go deeper, you can pass in additional `docker run` arguments
83
- # Same as: docker run -v /host:/container -p 1234:3306 user/patched-mysql /usr/bin/mysql
84
- docker.run mysql: { additional_run_args: '-v /host:/container -p 1234:3306', image: 'user/patched-mysql', cmd: '/usr/bin/mysql'}
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. An example of usage
116
- will be provided _"soon"_.
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
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/fgrehm/vocker/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
@@ -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 'ubuntu', 'busybox'
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
- vm2.vm.provision :docker
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
- # FIXME: We should make use of the config.ssh.username here
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 lxc-docker -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold'")
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
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  module Linux
5
5
  module DockerInstalled
6
6
  def self.docker_installed(machine)
7
- machine.communicate.test("test -d /var/lib/docker", sudo: true)
7
+ machine.communicate.test("test -f /usr/bin/docker", sudo: true)
8
8
  end
9
9
  end
10
10
  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
 
@@ -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
- args = "-cidfile=#{config[:cidfile]} -d"
66
- args << " -dns=#{config[:dns]}" if config[:dns]
67
- args << " #{config[:additional_run_args]}" if config[:additional_run_args]
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
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Vocker
3
- VERSION = "0.3.3"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  end
@@ -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
- it 'automatically assigns a digest of the command as the cidfile if not specified' do
39
- stub(communicator).test(with{|cmd| cmd =~ /docker ps/}) { false }
40
- stub(Digest::SHA1).hexdigest('mysql') { 'digest' }
41
- subject.run containers
42
- expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-cidfile=\/var\/lib\/vocker\/cids\/digest/})
43
- end
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
- it 'allows cidfile to be specified' do
46
- stub(communicator).test(with{|cmd| cmd =~ /docker ps/}) { false }
47
- containers['mysql'][:cidfile] = '/foo/bla'
48
- subject.run containers
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
- it 'allows a dns to be specified' do
53
- stub(communicator).test(with{|cmd| cmd =~ /docker ps/}) { false }
54
- containers['mysql'][:dns] = '127.0.0.1'
55
- subject.run containers
56
- expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-dns=127\.0\.0\.1/})
57
- end
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
- it 'allows additional params to be passed to the run command if specified' do
60
- stub(communicator).test(with{|cmd| cmd =~ /docker ps/}) { false }
61
- containers['mysql'][:additional_run_args] = '-p 49176:5601 -p 49175:514'
62
- subject.run containers
63
- expect(communicator).to have_received.sudo(with{|cmd| cmd =~ /-p 49176:5601 -p 49175:514/})
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.3.3
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-10-15 00:00:00.000000000 Z
11
+ date: 2013-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler