vagrant-docker-exec 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -2
- data/README.md +77 -11
- data/lib/vagrant-docker-exec/command/exec.rb +6 -1
- data/lib/vagrant-docker-exec/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 155ffbcbbfec33a327d2b9b6ca2f4b699008bd26
|
4
|
+
data.tar.gz: 68ae686a177b542528685d50572fa52f959491e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa3666d20522139c77a10f67828f35aeb2fbb1456f0ea04124de1bc0bc3aba1107f98aca67c06c0b9f96fabe23b799b5a3998732821e33c92949d8488da6289c
|
7
|
+
data.tar.gz: 9ff983923ceab8c2faca130b20f3412911267fe91e950bdda4280fec68c3d215282f879e1e1059515d0226a34aecebb2aa869ede989281c64680d5ac66468fa1
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
|
1
|
+
## 0.1.2 (March 5, 2015)
|
2
|
+
|
3
|
+
* Exec commands terminal output is now diplayed
|
4
|
+
|
5
|
+
## 0.1.1 (March 1, 2015)
|
2
6
|
|
3
7
|
* Fixed a bug that caused exec commands to fail
|
4
8
|
|
5
|
-
|
9
|
+
## 0.1.0 (March 1, 2015)
|
6
10
|
|
7
11
|
* Initial release.
|
data/README.md
CHANGED
@@ -1,43 +1,109 @@
|
|
1
1
|
# vagrant-docker-exec
|
2
|
-
|
3
|
-
This plugin allows you to run `docker exec` on a running container.
|
2
|
+
This plugin allows you to run `docker exec` commands from your host. When running docker in a proxy, this will save you the effort of sshing into the proxy to run `docker exec`. If you have multiple running containers, you can exec a command that runs on each container sequentially. Visit [Docker's command reference](https://docs.docker.com/reference/commandline/cli/#exec) for details on the exec command.
|
4
3
|
|
5
4
|
## Known Issues
|
5
|
+
Docker exec requires Docker 1.3.0 or higher. On non-Linux system, the docker in boot2docker provided by Vagrant is version 1.2 and does not support the exec command, so a custom docker host is required.
|
6
6
|
|
7
|
-
|
8
|
-
this plugin until boot2docker is updated.
|
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:
|
9
8
|
|
10
|
-
|
9
|
+
```ruby
|
10
|
+
# -*- mode: ruby -*-
|
11
|
+
# vi: set ft=ruby :
|
12
|
+
Vagrant.configure(2) do |config|
|
13
|
+
config.vm.box = "phusion/ubuntu-14.04-amd64"
|
14
|
+
config.vm.provision "docker"
|
15
|
+
config.vm.network :forwarded_port, host: 80, guest: 80
|
16
|
+
config.vm.provider :virtualbox do |vb|
|
17
|
+
vb.name = "docker-exec-proxy"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
```
|
11
21
|
|
12
|
-
|
22
|
+
And then use the vagrant_vagrantfile setting to reference your custom host in your Vagrantfile:
|
23
|
+
|
24
|
+
```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
|
35
|
+
end
|
36
|
+
end
|
37
|
+
```
|
13
38
|
|
39
|
+
This plugin has been tested on Mac OS X and VirtualBox.
|
40
|
+
|
41
|
+
## Getting Started
|
14
42
|
To install the plugin, run the following command:
|
15
43
|
```bash
|
16
44
|
vagrant plugin install vagrant-docker-exec
|
17
45
|
```
|
18
46
|
|
19
47
|
## Usage
|
48
|
+
A common use case for the exec command is to open a new shell in a running conatiner. To make it easy, run the `docker-shell` shortcut:
|
49
|
+
```bash
|
50
|
+
vagrant docker-shell [container]
|
51
|
+
```
|
20
52
|
|
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.
|
54
|
+
|
55
|
+
`docker-shell` is a shortcut for running Bash in an interactive shell:
|
56
|
+
```bash
|
57
|
+
vagrant docker-exec -t nginx -- bash
|
58
|
+
```
|
59
|
+
|
60
|
+
The syntax for `docker-exec` is:
|
21
61
|
```bash
|
22
62
|
vagrant docker-exec [options] [container] -- [command] [args]
|
23
63
|
```
|
24
|
-
--[no-]detach Run in the background
|
25
64
|
|
65
|
+
Options are:
|
66
|
+
--[no-]detach Run in the background
|
26
67
|
-t, --[no-]tty Open an interactive shell
|
27
68
|
|
28
|
-
|
69
|
+
Everything after the double hyphen is sent to docker's exec command.
|
70
|
+
|
71
|
+
As an example, to create a new file in a container named `nginx`:
|
29
72
|
|
30
73
|
```bash
|
31
74
|
vagrant docker-exec nginx -- touch /var/www/html/test.html
|
32
75
|
```
|
33
76
|
|
34
|
-
|
77
|
+
If the command produces output, the output will be prefixed with the name of the container.
|
78
|
+
```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
|
90
|
+
==> nginx: inet addr:127.0.0.1 Mask:255.0.0.0
|
91
|
+
==> 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)
|
97
|
+
```
|
35
98
|
|
99
|
+
The name of the container is only required for interactive shells. To run a command on multiple running containers, omit the container name:
|
36
100
|
```bash
|
37
|
-
vagrant docker-exec
|
101
|
+
vagrant docker-exec -- hostname
|
102
|
+
==> nginx: 231e57e57825
|
103
|
+
==> nginx2: 6ebced94866b
|
38
104
|
```
|
39
105
|
|
40
|
-
|
106
|
+
Note that all exec commands run by docker are run as the root user.
|
41
107
|
|
42
108
|
## Author
|
43
109
|
William Kolean william.kolean@gmail.com
|
@@ -76,7 +76,12 @@ module VagrantPlugins
|
|
76
76
|
#@env.ui.info(exec_cmd.flatten)
|
77
77
|
|
78
78
|
output = ""
|
79
|
-
machine.provider.driver.execute(*exec_cmd, exec_options)
|
79
|
+
machine.provider.driver.execute(*exec_cmd, exec_options) do |type, data|
|
80
|
+
output += data
|
81
|
+
end
|
82
|
+
|
83
|
+
output_options = {}
|
84
|
+
machine.ui.output(output.chomp!, **output_options) if !output.empty?
|
80
85
|
|
81
86
|
end
|
82
87
|
|
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.2
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
81
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.2.2
|
83
83
|
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: docker-exec runs a new command in a running container.
|