vagrant-docker-exec 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -2
- data/CHANGELOG.md +4 -0
- data/README.md +41 -38
- data/lib/vagrant-docker-exec/command/exec.rb +2 -2
- data/lib/vagrant-docker-exec/command/shell.rb +4 -6
- data/lib/vagrant-docker-exec/version.rb +1 -1
- 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: 8957378f186f209b14ab5fac4d3eafc58124c362
|
4
|
+
data.tar.gz: 551437aec60c3fb4afdf7cc1da07559b3f1a107e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1af27c6e07338d16825977cc879877d9a3933257d68106b56cd1b5ae899a7fe26c96fdeaf77db8b815463fa7df7673f617e208a07234a9b1c7272a512e89b364
|
7
|
+
data.tar.gz: 455c2ce6255fed03dcad309e6c0edd05d024927a6919ed125ec04fe83fc50dcefa87adfbf8b0b4e076474cf99a24d8b319584265284d063d42fe1bd2bd3c2bf1
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
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
|
-
|
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:
|
13
|
+
config.vm.network :forwarded_port, host: 8080, guest: 8080
|
16
14
|
config.vm.provider :virtualbox do |vb|
|
17
|
-
vb.name = "docker-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
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:
|
81
|
-
==> nginx:
|
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
|
-
==>
|
93
|
-
==>
|
94
|
-
==>
|
95
|
-
==>
|
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.
|
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.
|
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.
|
28
|
+
command << machine.id.to_s
|
29
29
|
command << "bash"
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
output += data
|
34
|
-
end
|
30
|
+
|
31
|
+
machine.provider.driver.execute(*command, options)
|
32
|
+
|
35
33
|
end
|
36
34
|
|
37
35
|
return 0
|
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.
|
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-
|
11
|
+
date: 2015-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|