From 960b00d85a974d4f46aa36fe0232b4814f78d53e Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 26 May 2020 14:12:19 +0200 Subject: [PATCH] Detect lxc (#1754) * Detect LXC on health check * fix lint * Update supervisor/core.py Co-authored-by: Franck Nijhof * fix black Co-authored-by: Franck Nijhof --- supervisor/core.py | 6 ++++++ supervisor/docker/__init__.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/supervisor/core.py b/supervisor/core.py index 93f546530..fa5a5ba56 100644 --- a/supervisor/core.py +++ b/supervisor/core.py @@ -48,6 +48,12 @@ class Core(CoreSysAttributes): "Docker version %s is not supported by Supervisor!", self.sys_docker.info.version, ) + elif self.sys_docker.info.inside_lxc: + self.healthy = False + _LOGGER.critical( + "Detected Docker running inside LXC. Running Home Assistant with the Supervisor on LXC is not supported!" + ) + self.sys_docker.info.check_requirements() # Check if system is healthy diff --git a/supervisor/docker/__init__.py b/supervisor/docker/__init__.py index a488ba2be..7f9361ae0 100644 --- a/supervisor/docker/__init__.py +++ b/supervisor/docker/__init__.py @@ -2,6 +2,7 @@ from contextlib import suppress from ipaddress import IPv4Address import logging +from pathlib import Path from typing import Any, Dict, Optional import attr @@ -46,6 +47,11 @@ class DockerInfo: return version_local >= version_min + @property + def inside_lxc(self) -> bool: + """Return True if the docker run inside lxc.""" + return Path("/dev/lxd/sock").exists() + def check_requirements(self) -> None: """Show wrong configurations.""" if self.storage != "overlay2":