Class: Ruuuby::MetaData::DockerAPI
Overview
for base gem documentation @see: github.com/swipely/docker-api
TODO: docs.docker.com/registry/spec/api/ TODO: registry.hub.docker.com/v2/ TODO: hub.docker.com/_/alpine?tab=tags TODO: hub.docker.com/_/nginx/
TODO: docs.docker.com/registry/spec/api
helpful CLI commands:
--------------------------------------------------------------------------------------------------------
| scenario | command/template/example | source |
| --------------------------------- | ----------------------------------------------------- | -------- |
| get container ID by name match | `docker ps -aqf "name=containername"` | https://stackoverflow.com/questions/34496882/get-docker-container-id-from-container-name |
| local multi-stage build | `docker build --target build_base` -t build_env_dev . | |
--------------------------------------------------------------------------------------------------------
helpful references: | | for info on | reference url | | ————— | ————————————————— | | docker ENV VARs | docs.docker.com/compose/reference/envvars/ |
‘🐋`
‘💎.engine.api_locale.api_docker`
Instance Attribute Summary collapse
#cmd_start
#versionable
Instance Method Summary
collapse
#_calculate_version, #executed_cmd_returned_expected_output, #run_cmd, #run_cmd_raw
#version
#∅?
Constructor Details
#initialize(engine, project_name) ⇒ DockerAPI
Returns a new instance of DockerAPI.
44
45
46
47
48
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 44
def initialize(engine, project_name)
super(engine, 'docker')
@project_name = project_name
end
|
Instance Attribute Details
TODO: create functions for all the prunes
41
42
43
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 41
def services
@services
end
|
Instance Method Details
#_connect(wait_for_connection) ⇒ Object
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 188
def _connect(wait_for_connection)
self.run_cmd_raw('open --hide --background -a Docker')
unless wait_for_connection
delta_ms = 77.0
delta_seconds = delta_ms / 1000.0
until self.connected?
@engine.debug("program set to sleep for{#{delta_ms.to_s}} ms")
sleep(delta_seconds)
delta_ms *= ::Float::RATIO_GOLDEN
delta_seconds = delta_ms / 1000.0
if delta_ms > 1337 * 3
delta_ms /= 2
end
end
end
end
|
#_disconnect ⇒ Object
183
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 183
def _disconnect; @engine.api.run_apple_script!('quit app "Docker"'); end
|
#_run_compose_cmd(cmd) ⇒ String
208
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 208
def _run_compose_cmd(cmd); @engine.api.run_cmd!("docker-compose #{cmd}"); end
|
#connect(wait_for_connection = false) ⇒ Object
73
74
75
76
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 73
def connect(wait_for_connection=false)
|
#connect!(wait_for_connection = false) ⇒ Object
81
82
83
84
85
86
87
88
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 81
def connect!(wait_for_connection=false)
|
#connected? ⇒ Boolean
Returns true, if the ‘Docker Engine` is currently running.
64
65
66
67
68
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 64
def connected?
::Docker.ping == 'OK'
rescue
false
end
|
#disconnect ⇒ Object
90
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 90
def disconnect; self._disconnect if self.connected?; end
|
#disconnect! ⇒ Object
93
94
95
96
97
98
99
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 93
def disconnect!
if self.connected?
self._disconnect
else
|
124
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 124
def find_
|
#find_🐋(container_name, exact_match = false) ⇒ Docker::Network
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 149
def find_
|
131
132
133
134
135
136
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 131
def find_
|
#healthy? ⇒ Boolean
53
54
55
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 53
def healthy?
self.healthy_env_api_versions? && self.healthy_env_compose_configs? && ::ENV['COMPOSE_PROJECT_NAME'] == 'ruuuby'
end
|
#healthy_env_api_versions? ⇒ Boolean
58
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 58
def healthy_env_api_versions?; ::ENV['DOCKER_API_VERSION'] == '1.40' && ::ENV['COMPOSE_API_VERSION'] == '1.40'; end
|
#healthy_env_compose_configs? ⇒ Boolean
61
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 61
def healthy_env_compose_configs?; ::ENV['COMPOSE_CONVERT_WINDOWS_PATHS'] == '1' && ::ENV['COMPOSE_PATH_SEPARATOR'] == ':'; end
|
#version_compose ⇒ String
175
176
177
178
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 175
def version_compose
@version_compose = self._run_compose_cmd('--version') if @version_compose.nil?
@version_compose
end
|
Returns an array of all the alive containers.
139
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 139
def
|
#∃🌐?(network_name) ⇒ Boolean
104
105
106
107
108
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 104
def
|
#∃🐋?(container_name) ⇒ Boolean
113
114
115
116
117
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 113
def
|
#♻️_🌐(network_name) ⇒ Object
170
|
# File 'lib/ruuuby/ruuuby/api/docker/api_docker.rb', line 170
def
|