Browse Source

docker-compose/readme: fix support for home-assistant images >=2021.4.0 by mounting tmpfs for async_dns

```
2021-04-17 16:05:56 WARNING (Recorder) [homeassistant.components.recorder.util] The system could not validate that the sqlite3 database at //config/home-assistant_v2.db was shutdown cleanly
2021-04-17 16:05:57 ERROR (MainThread) [homeassistant.setup] Setup failed for dhcp: unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 192, in _async_setup_component
    component = integration.get_component()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 477, in get_component
    cache[self.domain] = importlib.import_module(self.pkg_path)
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/dhcp/__init__.py", line 11, in <module>
    from aiodiscover import DiscoverHosts
  File "/usr/local/lib/python3.8/site-packages/aiodiscover/__init__.py", line 11, in <module>
    from .discovery import DiscoverHosts  # noqa: F401
  File "/usr/local/lib/python3.8/site-packages/aiodiscover/discovery.py", line 5, in <module>
    from async_dns.core import REQUEST, DNSMessage, RandId, Record, types
  File "/usr/local/lib/python3.8/site-packages/async_dns/__init__.py", line 1, in <module>
    from .core import *
  File "/usr/local/lib/python3.8/site-packages/async_dns/core/__init__.py", line 5, in <module>
    from .config import *
  File "/usr/local/lib/python3.8/site-packages/async_dns/core/config/__init__.py", line 2, in <module>
    from .root import *
  File "/usr/local/lib/python3.8/site-packages/async_dns/core/config/root.py", line 16, in <module>
    os.makedirs(CONFIG_DIR, exist_ok=True)
  File "/usr/local/lib/python3.8/os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/home/hass/.config/async_dns'
2021-04-17 16:05:57 ERROR (MainThread) [homeassistant.setup] Unable to set up dependencies of default_config. Setup failed for dependencies: dhcp
2021-04-17 16:05:57 ERROR (MainThread) [homeassistant.setup] Setup failed for default_config: Could not set up all dependencies.
```

workaround may be removed after home-assistant images upgraded to `async_dns>=1.1.10`:
https://github.com/gera2ld/async_dns/pull/23/files

related issue: https://github.com/home-assistant/core/issues/49205
Fabian Peter Hammerle 3 years ago
parent
commit
05404db2c6
3 changed files with 27 additions and 2 deletions
  1. 2 0
      CHANGELOG.md
  2. 1 0
      README.md
  3. 24 2
      docker-compose.yml

+ 2 - 0
CHANGELOG.md

@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 - fixed empty home-assistant version string in `org.opencontainers.image.title` label
+- `docker-compose`: fix support for home-assistant images `>=2021.4.0` by mounting `tmpfs` for `async_dns`
+  (fixes: `PermissionError: [Errno 13] Permission denied: '/home/hass/.config/async_dns'`)
 
 ## [1.1.0] - 2021-04-17
 ### Added

+ 1 - 0
README.md

@@ -18,6 +18,7 @@ signed docker image hashes: https://github.com/fphammerle/docker-home-assistant/
 $ sudo docker run --name home_assistant \
     -v home_assistant_config:/config:rw \
     -p 8123:8123 \
+    --read-only --tmpfs /home/hass/.config/async_dns:mode=1777,size=4k
     --security-opt=no-new-privileges --cap-drop=all \
     --restart unless-stopped \
     fphammerle/home-assistant

+ 24 - 2
docker-compose.yml

@@ -1,4 +1,4 @@
-version: '2.2'
+version: '2.3'
 
 volumes:
   config:
@@ -8,7 +8,29 @@ services:
     build: .
     image: fphammerle/home-assistant
     #read_only: true
-    volumes: ['config:/config:rw']
+    volumes:
+    - type: volume
+      source: config
+      target: /config
+      read_only: false
+    - type: tmpfs
+      # workaround for async_dns<1.1.10:
+      # >   File "/usr/local/lib/python3.8/site-packages/async_dns/core/config/root.py", line 16, in <module>
+      # >     os.makedirs(CONFIG_DIR, exist_ok=True)
+      # >   File "/usr/local/lib/python3.8/os.py", line 223, in makedirs
+      # >     mkdir(name, mode)
+      # > PermissionError: [Errno 13] Permission denied: '/home/hass/.config/async_dns'
+      # introduced in https://github.com/gera2ld/async_dns/commit/16cf6361ebfcc62fc6339e5194d013e8a8607fa2
+      # injected into home-assistant image >=2021.4.0 via
+      # - https://github.com/bdraco/aiodiscover/commit/d1db9a79df7c56b7930f04a79a36c2360ce8cd18#diff-610f365ee23052059bddd764ee702dce7e295c7b6563f1fd8980c8995205e079R6
+      # - https://github.com/home-assistant/core/commit/2ff94c8ed9fecd4dd7984d1f2d2600289c983a8b#diff-e441c4ef86b6cbecc1fe68515ed64a515941c872a72b40e85efbefc66ecb41b4R3
+      # fix: https://github.com/gera2ld/async_dns/pull/23/files
+      # https://github.com/gera2ld/async_dns/pull/23/commits/2e2bfd2a6428997191dce16d99d5a6d7ab70acd1
+      # related issue: https://github.com/home-assistant/core/issues/49205
+      target: /home/hass/.config/async_dns
+      tmpfs:
+        mode: 1777
+        size: 4k
     ports: ['127.0.0.1:8123:8123']
     cap_drop: [ALL]
     security_opt: [no-new-privileges]