Class: Kamal::Commands::Docker

Inherits:
Base
  • Object
show all
Defined in:
lib/kamal/commands/docker.rb

Constant Summary

Constants inherited from Base

Base::DOCKER_HEALTH_STATUS_FORMAT

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods inherited from Base

#container_id_for, #ensure_docker_installed, #initialize, #make_directory, #make_directory_for, #remove_directory, #remove_file, #run_over_ssh

Constructor Details

This class inherits a constructor from Kamal::Commands::Base

Instance Method Details

#add_to_docker_groupObject



30
31
32
# File 'lib/kamal/commands/docker.rb', line 30

def add_to_docker_group
  [ 'sudo -n usermod -aG docker "${USER:-$(id -un)}"' ]
end

#create_networkObject



38
39
40
# File 'lib/kamal/commands/docker.rb', line 38

def create_network
  docker :network, :create, :kamal
end

#in_docker_group?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/kamal/commands/docker.rb', line 26

def in_docker_group?
  [ 'id -nG "${USER:-$(id -un)}" | grep -qw docker' ]
end

#installObject

Install Docker using the github.com/docker/docker-install convenience script.



3
4
5
# File 'lib/kamal/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.

Returns:

  • (Boolean)


8
9
10
# File 'lib/kamal/commands/docker.rb', line 8

def installed?
  docker "-v"
end

#refresh_sessionObject



34
35
36
# File 'lib/kamal/commands/docker.rb', line 34

def refresh_session
  [ "kill -HUP $PPID" ]
end

#root?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/kamal/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.

Returns:

  • (Boolean)


13
14
15
# File 'lib/kamal/commands/docker.rb', line 13

def running?
  docker :version
end

#superuser?Boolean

Do we have superuser access to install Docker and start system services?

Returns:

  • (Boolean)


18
19
20
# File 'lib/kamal/commands/docker.rb', line 18

def superuser?
  [ '[ "${EUID:-$(id -u)}" -eq 0 ] || sudo -nl usermod >/dev/null' ]
end