Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions samcli/lib/build/app_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ def _build_function_on_container(self, # pylint: disable=too-many-locals
manifest_path,
runtime):

if not self._container_manager.is_docker_reachable:
raise BuildError("Docker is unreachable. Docker needs to be running to build inside a container.")

# If we are printing debug logs in SAM CLI, the builder library should also print debug logs
log_level = LOG.getEffectiveLevel()

Expand Down
16 changes: 16 additions & 0 deletions tests/unit/lib/build_module/test_app_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,22 @@ def test_must_raise_on_unsupported_container(self, LambdaBuildContainerMock):
self.assertEquals(str(ctx.exception), msg)
self.container_manager.stop.assert_called_with(container_mock)

def test_must_raise_on_docker_not_running(self):
config = Mock()

self.container_manager.is_docker_reachable = False

with self.assertRaises(BuildError) as ctx:
self.builder._build_function_on_container(config,
"source_dir",
"artifacts_dir",
"scratch_dir",
"manifest_path",
"runtime")

self.assertEquals(str(ctx.exception),
"Docker is unreachable. Docker needs to be running to build inside a container.")


class TestApplicationBuilder_parse_builder_response(TestCase):

Expand Down