lib/command/build_image.rb in cpl-0.3.3 vs lib/command/build_image.rb in cpl-0.4.0
- old
+ new
@@ -13,13 +13,24 @@
- Automatically assigns image numbers, e.g., `app:1`, `app:2`, etc.
- Uses `.controlplane/Dockerfile`
HEREDOC
def call
+ ensure_docker_running!
+
dockerfile = config.current[:dockerfile] || "Dockerfile"
dockerfile = "#{config.app_cpln_dir}/#{dockerfile}"
progress.puts "- Building dockerfile: #{dockerfile}"
cp.image_build(latest_image_next, dockerfile: dockerfile)
+ end
+
+ private
+
+ def ensure_docker_running!
+ `docker version > /dev/null 2>&1`
+ return if $?.success? # rubocop:disable Style/SpecialGlobalVars
+
+ Shell.abort("Can't run Docker. Please make sure that it's installed and started, then try again.")
end
end
end