mirror of
https://github.com/docker/compose.git
synced 2025-07-31 01:24:15 +02:00
Show clear error when docker binary can't be found
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
8314a48a2e
commit
925915eb25
@ -6,6 +6,7 @@ import contextlib
|
|||||||
import functools
|
import functools
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import pipes
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -415,7 +416,7 @@ class TopLevelCommand(object):
|
|||||||
tty = not options["-T"]
|
tty = not options["-T"]
|
||||||
|
|
||||||
if IS_WINDOWS_PLATFORM and not detach:
|
if IS_WINDOWS_PLATFORM and not detach:
|
||||||
args = ["docker", "exec"]
|
args = ["exec"]
|
||||||
|
|
||||||
if options["-d"]:
|
if options["-d"]:
|
||||||
args += ["--detach"]
|
args += ["--detach"]
|
||||||
@ -434,7 +435,7 @@ class TopLevelCommand(object):
|
|||||||
args += [container.id]
|
args += [container.id]
|
||||||
args += command
|
args += command
|
||||||
|
|
||||||
sys.exit(subprocess.call(args))
|
sys.exit(call_docker(args))
|
||||||
|
|
||||||
create_exec_options = {
|
create_exec_options = {
|
||||||
"privileged": options["--privileged"],
|
"privileged": options["--privileged"],
|
||||||
@ -982,8 +983,7 @@ def run_one_off_container(container_options, project, service, options):
|
|||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
if IS_WINDOWS_PLATFORM:
|
if IS_WINDOWS_PLATFORM:
|
||||||
args = ["docker", "start", "--attach", "--interactive", container.id]
|
exit_code = call_docker(["start", "--attach", "--interactive", container.id])
|
||||||
exit_code = subprocess.call(args)
|
|
||||||
else:
|
else:
|
||||||
operation = RunOperation(
|
operation = RunOperation(
|
||||||
project.client,
|
project.client,
|
||||||
@ -1060,3 +1060,15 @@ def exit_if(condition, message, exit_code):
|
|||||||
if condition:
|
if condition:
|
||||||
log.error(message)
|
log.error(message)
|
||||||
raise SystemExit(exit_code)
|
raise SystemExit(exit_code)
|
||||||
|
|
||||||
|
|
||||||
|
def call_docker(args):
|
||||||
|
try:
|
||||||
|
executable_path = subprocess.check_output(["which", "docker"]).strip()
|
||||||
|
except subprocess.CalledProcessError:
|
||||||
|
raise UserError(errors.docker_not_found_msg("Couldn't find `docker` binary."))
|
||||||
|
|
||||||
|
args = [executable_path] + args
|
||||||
|
log.debug(" ".join(map(pipes.quote, args)))
|
||||||
|
|
||||||
|
return subprocess.call(args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user