Class: Dash::Commands::Docker
Constant Summary
Constants inherited from Base
Base::DOCKER_HEALTH_STATUS_FORMAT, Base::NO_HEALTHCHECK
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #add_to_docker_group ⇒ Object
-
#connect_legacy_network_containers ⇒ Object
Stage 3c: docker cannot rename a network, so
dashis created alongsidekamaland everything still on the old one is joined to the new one. - #create_network ⇒ Object
- #in_docker_group? ⇒ Boolean
-
#install ⇒ Object
Install Docker using the https://github.com/docker/docker-install convenience script.
-
#installed? ⇒ Boolean
Checks the Docker client version.
-
#manifest_available?(image) ⇒ Boolean
Checks that an image's manifest can be fetched from its registry.
- #refresh_session ⇒ Object
- #root? ⇒ Boolean
-
#running? ⇒ Boolean
Checks the Docker server version.
-
#superuser? ⇒ Boolean
Do we have superuser access to install Docker and start system services?.
Methods inherited from Base
#container_id_for, #ensure_docker_installed, #ensure_run_directory, #initialize, #make_directory, #make_directory_for, #read_file, #remove_directory, #remove_file, #run_over_ssh
Constructor Details
This class inherits a constructor from Dash::Commands::Base
Instance Method Details
#add_to_docker_group ⇒ Object
30 31 32 |
# File 'lib/dash/commands/docker.rb', line 30 def add_to_docker_group [ 'sudo -n usermod -aG docker "${USER:-$(id -un)}"' ] end |
#connect_legacy_network_containers ⇒ Object
Stage 3c: docker cannot rename a network, so dash is created alongside
kamal and everything still on the old one is joined to the new one.
App containers would be replaced by the next deploy anyway; accessories are
not, and that is the whole point — without this a renamed proxy cannot
reach db or redis. Connecting a container that is already attached
fails, so each connect tolerates its own failure rather than aborting the
sweep. The old network is never removed; that is documented manual cleanup
and stage 3d's code change.
56 57 58 59 60 61 62 63 |
# File 'lib/dash/commands/docker.rb', line 56 def connect_legacy_network_containers any \ combine( legacy_network_exists, pipe(legacy_network_container_names, connect_each_to_network) ), [ :true ] end |
#create_network ⇒ Object
43 44 45 |
# File 'lib/dash/commands/docker.rb', line 43 def create_network docker :network, :create, Dash::Configuration::Proxy::NETWORK end |
#in_docker_group? ⇒ Boolean
26 27 28 |
# File 'lib/dash/commands/docker.rb', line 26 def in_docker_group? [ 'id -nG "${USER:-$(id -un)}" | grep -qw docker' ] end |
#install ⇒ Object
Install Docker using the https://github.com/docker/docker-install convenience script.
3 4 5 |
# File 'lib/dash/commands/docker.rb', line 3 def install pipe get_docker, :sh end |
#installed? ⇒ Boolean
Checks the Docker client version. Fails if Docker is not installed.
8 9 10 |
# File 'lib/dash/commands/docker.rb', line 8 def installed? docker "-v" end |
#manifest_available?(image) ⇒ Boolean
Checks that an image's manifest can be fetched from its registry. Fails if it's missing or we're unauthorized.
39 40 41 |
# File 'lib/dash/commands/docker.rb', line 39 def manifest_available?(image) docker :manifest, :inspect, image end |
#refresh_session ⇒ Object
34 35 36 |
# File 'lib/dash/commands/docker.rb', line 34 def refresh_session [ "kill -HUP $PPID" ] end |
#root? ⇒ Boolean
22 23 24 |
# File 'lib/dash/commands/docker.rb', line 22 def root? [ '[ "${EUID:-$(id -u)}" -eq 0 ]' ] end |
#running? ⇒ Boolean
Checks the Docker server version. Fails if Docker is not running.
13 14 15 |
# File 'lib/dash/commands/docker.rb', line 13 def running? docker :version end |
#superuser? ⇒ Boolean
Do we have superuser access to install Docker and start system services?
18 19 20 |
# File 'lib/dash/commands/docker.rb', line 18 def superuser? [ '[ "${EUID:-$(id -u)}" -eq 0 ] || sudo -nl usermod >/dev/null' ] end |