vagrant-docker-exec 0.1.2 → 0.1.3

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: 155ffbcbbfec33a327d2b9b6ca2f4b699008bd26
4
- data.tar.gz: 68ae686a177b542528685d50572fa52f959491e3
3
+ metadata.gz: 8957378f186f209b14ab5fac4d3eafc58124c362
4
+ data.tar.gz: 551437aec60c3fb4afdf7cc1da07559b3f1a107e
5
5
  SHA512:
6
- metadata.gz: aa3666d20522139c77a10f67828f35aeb2fbb1456f0ea04124de1bc0bc3aba1107f98aca67c06c0b9f96fabe23b799b5a3998732821e33c92949d8488da6289c
7
- data.tar.gz: 9ff983923ceab8c2faca130b20f3412911267fe91e950bdda4280fec68c3d215282f879e1e1059515d0226a34aecebb2aa869ede989281c64680d5ac66468fa1
6
+ metadata.gz: 1af27c6e07338d16825977cc879877d9a3933257d68106b56cd1b5ae899a7fe26c96fdeaf77db8b815463fa7df7673f617e208a07234a9b1c7272a512e89b364
7
+ data.tar.gz: 455c2ce6255fed03dcad309e6c0edd05d024927a6919ed125ec04fe83fc50dcefa87adfbf8b0b4e076474cf99a24d8b319584265284d063d42fe1bd2bd3c2bf1
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  .vagrant
2
2
  Gemfile.lock
3
- Vagrantfile
4
- Vagrantfile.proxy
3
+ Vagrantfile*
5
4
  www
6
5
  pkg
@@ -1,3 +1,7 @@
1
+ ## 0.1.3 (March 7, 2015)
2
+
3
+ * Exec commands now use machine id and no longer expects a container name
4
+
1
5
  ## 0.1.2 (March 5, 2015)
2
6
 
3
7
  * Exec commands terminal output is now diplayed
data/README.md CHANGED
@@ -7,14 +7,12 @@ Docker exec requires Docker 1.3.0 or higher. On non-Linux system, the docker in
7
7
  You can find more information on setting up a custom docker host on the [Vagrant blog](http://www.vagrantup.com/blog/feature-preview-vagrant-1-6-docker-dev-environments.html) but basically, create Vagrantfile.proxy:
8
8
 
9
9
  ```ruby
10
- # -*- mode: ruby -*-
11
- # vi: set ft=ruby :
12
- Vagrant.configure(2) do |config|
10
+ Vagrant.configure("2") do |config|
13
11
  config.vm.box = "phusion/ubuntu-14.04-amd64"
14
12
  config.vm.provision "docker"
15
- config.vm.network :forwarded_port, host: 80, guest: 80
13
+ config.vm.network :forwarded_port, host: 8080, guest: 8080
16
14
  config.vm.provider :virtualbox do |vb|
17
- vb.name = "docker-exec-proxy"
15
+ vb.name = "docker-proxy"
18
16
  end
19
17
  end
20
18
  ```
@@ -22,16 +20,11 @@ end
22
20
  And then use the vagrant_vagrantfile setting to reference your custom host in your Vagrantfile:
23
21
 
24
22
  ```ruby
25
- # -*- mode: ruby -*-
26
- # vi: set ft=ruby :
27
- Vagrant.configure(2) do |config|
28
- config.vm.define "nginx" do |v|
29
- v.vm.provider "docker" do |d|
30
- d.image = "dockerfile/nginx"
31
- d.ports = ["80:80"]
32
- d.name = "nginx"
33
- d.vagrant_vagrantfile = "./Vagrantfile.proxy"
34
- end
23
+ Vagrant.configure("2") do |config|
24
+ config.vm.provider "docker" do |d|
25
+ d.image = "dockerfile/nginx"
26
+ d.ports = ["8080:80"]
27
+ d.vagrant_vagrantfile = "./Vagrantfile.proxy"
35
28
  end
36
29
  end
37
30
  ```
@@ -50,9 +43,9 @@ A common use case for the exec command is to open a new shell in a running conat
50
43
  vagrant docker-shell [container]
51
44
  ```
52
45
 
53
- If you're running a docker host, then you are running in a multi-host environment and the container name is required, even if only one docker container is running.
46
+ In a single machine environment you can omit the container name and just run `vagrant docker-shell`.
54
47
 
55
- `docker-shell` is a shortcut for running Bash in an interactive shell:
48
+ `docker-shell` is a shortcut for `docker-exec` running Bash in an interactive shell:
56
49
  ```bash
57
50
  vagrant docker-exec -t nginx -- bash
58
51
  ```
@@ -62,38 +55,43 @@ The syntax for `docker-exec` is:
62
55
  vagrant docker-exec [options] [container] -- [command] [args]
63
56
  ```
64
57
 
65
- Options are:
66
- --[no-]detach Run in the background
58
+ Options are:
59
+ --[no-]detach Run in the background
67
60
  -t, --[no-]tty Open an interactive shell
68
61
 
69
- Everything after the double hyphen is sent to docker's exec command.
62
+ In a multimachine environment `docker-exec` (and `docker-shell`) must be followed by at least 1 container name defined by `config.vm.define`. For example, for this Vagrantfile
63
+ ```ruby
64
+ Vagrant.configure("2") do |config|
65
+ config.vm.define "web" do |v|
66
+ v.vm.provider "docker" do |d|
67
+ d.image = "dockerfile/nginx"
68
+ d.ports = ["8082:80"]
69
+ d.name = "nginx"
70
+ d.vagrant_vagrantfile = "./Vagrantfile.proxy"
71
+ end
72
+ end
73
+ end
74
+ ```
70
75
 
71
- As an example, to create a new file in a container named `nginx`:
76
+ The container name passed to `docker-exec` is `web` even though a docker assigned the container the name "nginx".
72
77
 
78
+ ## Examples
79
+ Everything after the double hyphen is sent to docker's exec command. For example, to create a new file in a container named nginx:
73
80
  ```bash
74
- vagrant docker-exec nginx -- touch /var/www/html/test.html
81
+ vagrant docker-exec web -- touch /var/www/html/test.html
75
82
  ```
76
83
 
77
84
  If the command produces output, the output will be prefixed with the name of the container.
78
85
  ```bash
79
- vagrant docker-exec nginx -- ifconfig
80
- ==> nginx: eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02
81
- ==> nginx: inet addr:172.17.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
82
- ==> nginx: inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
83
- ==> nginx: UP BROADCAST RUNNING MTU:1500 Metric:1
84
- ==> nginx: RX packets:24 errors:0 dropped:0 overruns:0 frame:0
85
- ==> nginx: TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
86
- ==> nginx: collisions:0 txqueuelen:0
87
- ==> nginx: RX bytes:1944 (1.9 KB) TX bytes:648 (648.0 B)
88
- ==> nginx:
89
- ==> nginx: lo Link encap:Local Loopback
86
+ vagrant docker-exec nginx nginx2 -- ifconfig | grep inet
87
+ ==> nginx: inet addr:172.17.0.5 Bcast:0.0.0.0 Mask:255.255.0.0
88
+ ==> nginx: inet6 addr: fe80::42:acff:fe11:5/64 Scope:Link
90
89
  ==> nginx: inet addr:127.0.0.1 Mask:255.0.0.0
91
90
  ==> nginx: inet6 addr: ::1/128 Scope:Host
92
- ==> nginx: UP LOOPBACK RUNNING MTU:65536 Metric:1
93
- ==> nginx: RX packets:0 errors:0 dropped:0 overruns:0 frame:0
94
- ==> nginx: TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
95
- ==> nginx: collisions:0 txqueuelen:0
96
- ==> nginx: RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
91
+ ==> nginx2: inet addr:172.17.0.4 Bcast:0.0.0.0 Mask:255.255.0.0
92
+ ==> nginx2: inet6 addr: fe80::42:acff:fe11:4/64 Scope:Link
93
+ ==> nginx2: inet addr:127.0.0.1 Mask:255.0.0.0
94
+ ==> nginx2: inet6 addr: ::1/128 Scope:Host
97
95
  ```
98
96
 
99
97
  The name of the container is only required for interactive shells. To run a command on multiple running containers, omit the container name:
@@ -103,6 +101,11 @@ vagrant docker-exec -- hostname
103
101
  ==> nginx2: 6ebced94866b
104
102
  ```
105
103
 
104
+ You can also specify containers as you would any other vagrant command:
105
+ ```bash
106
+ vagrant docker-exec /nginx\d?/ -- ps aux | grep www-data
107
+ ```
108
+
106
109
  Note that all exec commands run by docker are run as the root user.
107
110
 
108
111
  ## Author
@@ -50,7 +50,7 @@ module VagrantPlugins
50
50
 
51
51
  with_target_vms(argv, target_opts) do |machine|
52
52
  if machine.state.id != :running
53
- @env.ui.info("#{machine.name} is not running.")
53
+ @env.ui.info("#{machine.id} is not running.")
54
54
  next
55
55
  end
56
56
 
@@ -65,7 +65,7 @@ module VagrantPlugins
65
65
 
66
66
  exec_cmd = %W(docker exec)
67
67
  exec_cmd << "-i" << "-t" if options[:pty]
68
- exec_cmd << machine.name.to_s
68
+ exec_cmd << machine.id.to_s
69
69
  exec_cmd += options[:extra_args] if options[:extra_args]
70
70
  exec_cmd.concat(command)
71
71
 
@@ -25,13 +25,11 @@ module VagrantPlugins
25
25
 
26
26
  with_target_vms(argv, target_opts) do |machine|
27
27
  command = ["docker", "exec", "-it"]
28
- command << machine.name.to_s
28
+ command << machine.id.to_s
29
29
  command << "bash"
30
-
31
- output = ""
32
- machine.provider.driver.execute(*command, options) do |type, data|
33
- output += data
34
- end
30
+
31
+ machine.provider.driver.execute(*command, options)
32
+
35
33
  end
36
34
 
37
35
  return 0
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module DockerExec
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-docker-exec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Kolean
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler