diff --git a/python/ray/autoscaler/command_runner.py b/python/ray/autoscaler/command_runner.py index cd38f09e7..2a15d528d 100644 --- a/python/ray/autoscaler/command_runner.py +++ b/python/ray/autoscaler/command_runner.py @@ -659,10 +659,11 @@ class DockerCommandRunner(CommandRunnerInterface): self.container_name) def _check_docker_installed(self): - try: - self.ssh_command_runner.run("command -v docker") - return - except Exception: + no_exist = "NoExist" + output = self.ssh_command_runner.run( + f"command -v docker || echo '{no_exist}'", with_output=True) + cleaned_output = output.decode().strip() + if no_exist in cleaned_output or "docker" not in cleaned_output: install_commands = [ "curl -fsSL https://get.docker.com -o get-docker.sh", "sudo sh get-docker.sh", "sudo usermod -aG docker $USER",