Module: DockerSync::Dependencies::Docker

Defined in:
lib/docker-sync/dependencies/docker.rb,
lib/docker-sync/dependencies/docker_driver.rb

Defined Under Namespace

Modules: Driver

Constant Summary collapse

DOCKER_NOT_AVAILABLE =
'Could not find Docker. Please install it (see https://docs.docker.com/compose/install/) and try again.'.freeze
DOCKER_NOT_RUNNING =
'No docker daemon seems to be running. Did you start docker-engine / docker-for-mac / docker-machine?'.freeze

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/docker-sync/dependencies/docker.rb', line 7

def self.available?
  return @available if defined? @available
  @available = find_executable0('docker')
end

.ensure!Object



17
18
19
20
# File 'lib/docker-sync/dependencies/docker.rb', line 17

def self.ensure!
  raise(DOCKER_NOT_AVAILABLE) unless available?
  raise(DOCKER_NOT_RUNNING)   unless running?
end

.running?Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/docker-sync/dependencies/docker.rb', line 12

def self.running?
  return @running if defined? @running
  @running = system('docker ps > /dev/null 2>&1')
end