vagrant-docker-exec 0.1.3 → 0.1.4
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/.gitignore +2 -0
- data/CHANGELOG.md +4 -0
- data/README.md +23 -8
- data/lib/vagrant-docker-exec/command/exec.rb +9 -2
- 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: e8e9d37811dfd1f8eba7e1f4154eb7075de8708c
|
4
|
+
data.tar.gz: cc16af1013738a246c7a4d3e984e446c8ed645f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b82a4e0863011b47cb9225f85113e42666f98f107e4c4d36dc47a24bfa978664f9e12de2476774ddecf9b265a0925808b62ffec03550e0124f94d375fbf40428
|
7
|
+
data.tar.gz: c1d6cbb87ad7ed36d89ab83897c7227868579393d6824bdd68d14c9961dd86f1f1d2ece9ae7197923f5e5123cdf068b5c2c0f5abd27b03b2d4d6055dcd694b04
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,9 +2,13 @@
|
|
2
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.
|
3
3
|
|
4
4
|
## Known Issues
|
5
|
-
|
5
|
+
When running vagrant on Linux, interactive shells fail to return output with Vagrant 1.7.2 running on Ubuntu 14 Trusty Tahr. It appears to be a problem inherent to Vagrant 1.7.2 because built in commands like `vagrant docker run` also fail to return output from a shell. There is no known workaround at this time.
|
6
6
|
|
7
|
-
|
7
|
+
A container must be running before running `docker exec`, it will not be started automatically.
|
8
|
+
|
9
|
+
`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.
|
10
|
+
|
11
|
+
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 and forward all your ports:
|
8
12
|
|
9
13
|
```ruby
|
10
14
|
Vagrant.configure("2") do |config|
|
@@ -37,6 +41,11 @@ To install the plugin, run the following command:
|
|
37
41
|
vagrant plugin install vagrant-docker-exec
|
38
42
|
```
|
39
43
|
|
44
|
+
Periodically check for updates:
|
45
|
+
```bash
|
46
|
+
vagrant plugin update
|
47
|
+
```
|
48
|
+
|
40
49
|
## Usage
|
41
50
|
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:
|
42
51
|
```bash
|
@@ -52,14 +61,15 @@ vagrant docker-exec -t nginx -- bash
|
|
52
61
|
|
53
62
|
The syntax for `docker-exec` is:
|
54
63
|
```bash
|
55
|
-
vagrant docker-exec [options] [container] --
|
64
|
+
vagrant docker-exec [options] [container] -- <command> [args]
|
56
65
|
```
|
57
66
|
|
58
67
|
Options are:
|
59
|
-
|
60
|
-
|
68
|
+
-t, \-\-[no-]tty Open an interactive shell
|
69
|
+
\-\-[no-]prefix Prefix output with machine names
|
70
|
+
\-\-[no-]detach Run in the background
|
61
71
|
|
62
|
-
|
72
|
+
When opening a shell in a multimachine environment, `docker-exec -t` (and `docker-shell`) must be followed by at least 1 container name defined by `config.vm.define`. For example, for this Vagrantfile
|
63
73
|
```ruby
|
64
74
|
Vagrant.configure("2") do |config|
|
65
75
|
config.vm.define "web" do |v|
|
@@ -73,10 +83,10 @@ Vagrant.configure("2") do |config|
|
|
73
83
|
end
|
74
84
|
```
|
75
85
|
|
76
|
-
The
|
86
|
+
The vagrant identifier is `web` so the command to open a shell will be `vagrant docker-exec -t web -- bash` even though the command `docker ps` will list the container name as "nginx". To avoid confusion it's best to use the same name for `config.vm.define` and `d.name`.
|
77
87
|
|
78
88
|
## Examples
|
79
|
-
|
89
|
+
Arguments after the double hyphen are sent to docker's exec command. For example, to create a new file in a container named nginx:
|
80
90
|
```bash
|
81
91
|
vagrant docker-exec web -- touch /var/www/html/test.html
|
82
92
|
```
|
@@ -94,6 +104,11 @@ vagrant docker-exec nginx nginx2 -- ifconfig | grep inet
|
|
94
104
|
==> nginx2: inet6 addr: ::1/128 Scope:Host
|
95
105
|
```
|
96
106
|
|
107
|
+
To omit the container name prefix, pass the option \-\-no-prefix:
|
108
|
+
```bash
|
109
|
+
bundle exec vagrant docker-exec --no-prefix -- head -n 1 /etc/hosts
|
110
|
+
```
|
111
|
+
|
97
112
|
The name of the container is only required for interactive shells. To run a command on multiple running containers, omit the container name:
|
98
113
|
```bash
|
99
114
|
vagrant docker-exec -- hostname
|
@@ -9,9 +9,10 @@ module VagrantPlugins
|
|
9
9
|
options = {}
|
10
10
|
options[:detach] = false
|
11
11
|
options[:pty] = false
|
12
|
+
options[:prefix] = true
|
12
13
|
|
13
14
|
opts = OptionParser.new do |o|
|
14
|
-
o.banner = "Usage: vagrant docker-exec [command
|
15
|
+
o.banner = "Usage: vagrant docker-exec [options] [container] -- <command> [args]"
|
15
16
|
o.separator ""
|
16
17
|
o.separator "Options:"
|
17
18
|
o.separator ""
|
@@ -23,6 +24,10 @@ module VagrantPlugins
|
|
23
24
|
o.on("-t", "--[no-]tty", "Allocate a pty") do |t|
|
24
25
|
options[:pty] = t
|
25
26
|
end
|
27
|
+
|
28
|
+
o.on("--[no-]prefix", "Prefix output with machine names") do |p|
|
29
|
+
options[:prefix] = p
|
30
|
+
end
|
26
31
|
end
|
27
32
|
|
28
33
|
# Parse out the extra args to send to SSH, which is everything
|
@@ -63,7 +68,7 @@ module VagrantPlugins
|
|
63
68
|
|
64
69
|
def exec_command(machine, options, command)
|
65
70
|
|
66
|
-
exec_cmd = %
|
71
|
+
exec_cmd = %w(docker exec)
|
67
72
|
exec_cmd << "-i" << "-t" if options[:pty]
|
68
73
|
exec_cmd << machine.id.to_s
|
69
74
|
exec_cmd += options[:extra_args] if options[:extra_args]
|
@@ -81,6 +86,8 @@ module VagrantPlugins
|
|
81
86
|
end
|
82
87
|
|
83
88
|
output_options = {}
|
89
|
+
output_options[:prefix] = false if !options[:prefix]
|
90
|
+
|
84
91
|
machine.ui.output(output.chomp!, **output_options) if !output.empty?
|
85
92
|
|
86
93
|
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.
|
4
|
+
version: 0.1.4
|
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-
|
11
|
+
date: 2015-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|