dockerapi 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +17 -3
- data/bin/setup +17 -3
- data/lib/docker/api/connection.rb +4 -0
- data/lib/docker/api/exec.rb +39 -0
- data/lib/docker/api/version.rb +1 -1
- data/lib/dockerapi.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90acd383975c4846ca2d6bfb91aa15d9898ce0101557ca50481f20729871ef73
|
4
|
+
data.tar.gz: 03d01594692f5c2093bf3e91b4f67635d2bd8e1bf0360217747ea4aa8d2c6840
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56a36a3c8b73fc0a8ae02cc68bd93b6b858be21d8c9c6d033b5f1d34d581f646dbb9e77df2e0a9d216c2a835eec3bd8e1abb62ade82aa6ec818ef081b5181d5d
|
7
|
+
data.tar.gz: 101c74b35333664dc5573d5443f2c7d75d5c8de9a43a2f70a7a54e5bb5673091eebe31dfc9ed5845c1052f47907dc6d7873f3bbe84a5015e10f5411458993cb9
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -37,7 +37,6 @@ Docker::API::Image.create( fromSrc: "https://url.to/file.tar", repo: "repo:tag"
|
|
37
37
|
|
38
38
|
# List images
|
39
39
|
Docker::API::Image.list
|
40
|
-
Docker::API::Image.list( all:true )
|
41
40
|
|
42
41
|
# Inspect image
|
43
42
|
Docker::API::Image.inspect("image")
|
@@ -59,7 +58,7 @@ Docker::API::Image.push("repo:tag") # to dockerhub
|
|
59
58
|
Docker::API::Image.push("localhost:5000/repo:tag") # to local registry
|
60
59
|
Docker::API::Image.push("private/repo", {tag: "tag"}, {username: "janedoe", password: "password"} # to private repository
|
61
60
|
|
62
|
-
# Remove
|
61
|
+
# Remove image
|
63
62
|
Docker::API::Image.remove("image")
|
64
63
|
Docker::API::Image.remove("image", force: true)
|
65
64
|
|
@@ -215,6 +214,21 @@ Docker::API::System.events(until: Time.now.to_i)
|
|
215
214
|
Docker::API::System.df
|
216
215
|
```
|
217
216
|
|
217
|
+
### Exec
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
# Create exec instance, get generated exec ID
|
221
|
+
response = Docker::API::Exec.create(container, AttachStdout:true, Cmd: ["ls", "-l"])
|
222
|
+
id = response.json["Id"]
|
223
|
+
|
224
|
+
# Execute the command, stream from Stdout is stored in response data
|
225
|
+
response = Docker::API::Exec.start(id)
|
226
|
+
print response.data[:stream]
|
227
|
+
|
228
|
+
# Inspect exec instance
|
229
|
+
Docker::API::Exec.inspect(id)
|
230
|
+
```
|
231
|
+
|
218
232
|
### Requests
|
219
233
|
|
220
234
|
Requests should work as described in [Docker API documentation](https://docs.docker.com/engine/api/v1.40). Check it out to customize your requests.
|
@@ -275,7 +289,7 @@ WIP: Work In Progress
|
|
275
289
|
| Volume | Ok | Ok | NS |
|
276
290
|
| Network | Ok | Ok | NS |
|
277
291
|
| System | Ok | Ok | NS |
|
278
|
-
| Exec |
|
292
|
+
| Exec | Ok | Ok | NS |
|
279
293
|
| Swarm | NS | NS | NS |
|
280
294
|
| Node | NS | NS | NS |
|
281
295
|
| Service | NS | NS | NS |
|
data/bin/setup
CHANGED
@@ -1,8 +1,22 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
set -euo pipefail
|
3
3
|
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
4
|
+
#set -vx
|
7
5
|
|
8
6
|
# Do any other automated setup that you need to do here
|
7
|
+
if [ $USER == 'root' ]
|
8
|
+
then
|
9
|
+
echo "Enabling TCP port 2375 for external connection to Docker"
|
10
|
+
echo '{"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}' > /etc/docker/daemon.json
|
11
|
+
mkdir -p /etc/systemd/system/docker.service.d
|
12
|
+
echo '[Service]' > /etc/systemd/system/docker.service.d/override.conf
|
13
|
+
echo 'ExecStart=' >> /etc/systemd/system/docker.service.d/override.conf
|
14
|
+
echo 'ExecStart=/usr/bin/dockerd' >> /etc/systemd/system/docker.service.d/override.conf
|
15
|
+
systemctl daemon-reload
|
16
|
+
systemctl restart docker.service
|
17
|
+
echo "Done!"
|
18
|
+
else
|
19
|
+
echo "Running bundle install"
|
20
|
+
bundle install
|
21
|
+
echo "Run this script as root for further configurations"
|
22
|
+
fi
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Docker
|
2
|
+
module API
|
3
|
+
class Exec < Docker::API::Base
|
4
|
+
|
5
|
+
def self.base_path
|
6
|
+
"/exec"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.create name, body = {}
|
10
|
+
validate Docker::API::InvalidRequestBody, [:AttachStdin, :AttachStdout, :AttachStderr, :DetachKeys, :Tty, :Env, :Cmd, :Privileged, :User, :WorkingDir], body
|
11
|
+
connection.request(method: :post, path: "/containers/#{name}/exec", headers: {"Content-Type": "application/json"}, body: body.to_json )
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.start name, body = {}
|
15
|
+
validate Docker::API::InvalidRequestBody, [:Detach, :Tty], body
|
16
|
+
|
17
|
+
stream = ""
|
18
|
+
response = connection.request(method: :post,
|
19
|
+
path: "/exec/#{name}/start",
|
20
|
+
headers: {"Content-Type": "application/json"},
|
21
|
+
body: body.to_json,
|
22
|
+
response_block: lambda { |chunk, remaining_bytes, total_bytes| stream += chunk.to_s.encode('UTF-8', invalid: :replace, undef: :replace, replace: '?') }
|
23
|
+
)
|
24
|
+
response.data.merge!({stream: stream})
|
25
|
+
response
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.resize name, params = {}
|
29
|
+
validate Docker::API::InvalidParameter, [:w, :h], params
|
30
|
+
connection.post(build_path([name, "resize"], params))
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.inspect name
|
34
|
+
connection.get(build_path([name, "json"]))
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/docker/api/version.rb
CHANGED
data/lib/dockerapi.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockerapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alysson A. Costa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/docker/api/connection.rb
|
48
48
|
- lib/docker/api/container.rb
|
49
49
|
- lib/docker/api/error.rb
|
50
|
+
- lib/docker/api/exec.rb
|
50
51
|
- lib/docker/api/image.rb
|
51
52
|
- lib/docker/api/network.rb
|
52
53
|
- lib/docker/api/response.rb
|