Skip to content

Commit

Permalink
Detects missing or inactive Docker daemon and returns a helpful error.
Browse files Browse the repository at this point in the history
…Closes #362
  • Loading branch information
mwvaughn committed Sep 28, 2021
1 parent a96db16 commit 20993d0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tapis_cli/commands/taccapis/v2/actors/deploy/deploy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import docker as dockerpy
import requests
import os
import urllib.parse

Expand Down Expand Up @@ -243,11 +244,22 @@ def _dockerfile(self):
# TODO - handle working directory
return self.config.get('docker', {}).get('dockerfile', 'Dockerfile')

def _dockerpy_test(self):
try:
self.dockerpy.images.list()
except requests.exceptions.ConnectionError:
raise SystemError(
'Unable to communicate with Docker daemon. Is Docker installed and active?'
)
except Exception:
raise

def _build(self, parsed_args):
"""Build container
"""
if self.build:
try:
self._dockerpy_test()
tag = self._repo_tag()
dockerfile = self._dockerfile()
print_stderr('Building {}'.format(tag))
Expand Down Expand Up @@ -279,6 +291,7 @@ def _push(self, parsed_args):
"""
if self.push:
try:
self._dockerpy_test()
tag = self._repo_tag()
print_stderr('Pushing {}'.format(tag))
start_time = milliseconds()
Expand Down
13 changes: 13 additions & 0 deletions tapis_cli/commands/taccapis/v2/apps/deploy/deploy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import docker as dockerpy
import os
import requests
import urllib.parse
from datetime import datetime

Expand Down Expand Up @@ -308,11 +309,22 @@ def _bundle(self):
bundle_path = os.path.join(self.working_dir, DEFAULT_BUNDLE_NAME)
return self.config['app'].get('bundle', bundle_path)

def _dockerpy_test(self):
try:
self.dockerpy.images.list()
except requests.exceptions.ConnectionError:
raise SystemError(
'Unable to communicate with Docker daemon. Is Docker installed and active?'
)
except Exception:
raise

def _build(self, parsed_args):
"""Build container
"""
if self.build:
try:
self._dockerpy_test()
tag = self._repo_tag()
dockerfile = self._dockerfile()
print_stderr('Building {}'.format(tag))
Expand Down Expand Up @@ -344,6 +356,7 @@ def _push(self, parsed_args):
"""
if self.push:
try:
self._dockerpy_test()
tag = self._repo_tag()
print_stderr('Pushing {}'.format(tag))
start_time = milliseconds()
Expand Down

0 comments on commit 20993d0

Please sign in to comment.