Home assistant in docker, access to host folders (folders outside of docker), running on QNAP NAS

Hi. First post in the HA community ever. Hi.

Question:
How can Home assistant running in docker access an image in a specific folder on the host machine?

Short version of the question

TL;DR:
If I’ve mounted an external docker path when installing docker and verified (indirectly, through doods) that HA can write to that path, why can’t HA read (display an image) from that specific path?

More info:
I’ve read a lot of info out there about this, but still failed to find a solution.
I have Home assistant 2021.2.1 installed from docker hub, running on a QNAP NAS (TS-453A)

I installed HA with

docker run -d \
    --network=host \
    --name home-assistant \
    [...]
    -v /share/CACHEDEV1_DATA/AppData/homeassistant:/config \
    -v /share/CACHEDEV1_DATA/Surveillance/captured_person_detection:/captured_person:rw \
    -v /etc/localtime:/etc/localtime:ro \
    --restart unless-stopped \
    homeassistant/home-assistant:2021.2.1

Note my attempt at mounting external path /share/CACHEDEV1_DATA/Surveillance/captured_person_detection as internal path /captured_person.

I then installed snowzach/doods:latest as another docker container and configured it in configuration.yaml with:

image_processing:
  - platform: doods
    file_out:
      - "/captured_person/camera_latest.jpg"

That’s not the full config above, I only included the relevant bits. Doods can be easily triggered with a service call to image_processing.scan which successfully creates the camera_latest.jpg within the /share/CACHEDEV1_DATA/Surveillance/captured_person_detection folder. Easy to see the jpg update, easy to browse to it from the NAS. All good so far.

What I’d love to do is display the captured image within HA somehow. My attempt was to create a generic camera in configuration.yaml and show the image:

camera:
  - platform: generic
    name: Virtual Cam
    still_image_url: /captured_person/camera_latest.jpg

When creating a Picture glance or Picture type of card,

type: picture-glance
camera_image: camera.virtual_cam

This always gives me errors of this type in the docker log:
2021-02-12 11:12:49 ERROR (MainThread) [homeassistant.components.generic.camera] Error getting new camera image from Virtual Cam: /captured_person/camera_latest.jpg

I also tried adding

allowlist_external_dirs:
    - /captured_person

to my ‘homeassistant:’ section in configuration.yaml to no avail.

If I SSH into the NAS and ls -l from the folder, I get
-rw-r--r-- 1 admin administrators 338988 2021-02-11 10:59 camera_latest.jpg
and the folder the jpg is in reports
drwxrwxrwx 3 admin administrators 4096 2021-02-12 09:09 captured_person_detection/

I won’t claim to properly understand linux file permissions, but it looks to me like anyone can read the file?

I know I could change file paths to use the ‘/config/www’ approach, but I wouldn’t want to expose those images over internet and I also prefer to have them in that specific NAS folder (because other external tools would manage those images as well).

Did I approach this correctly? I assumed /captured_person is a valid path for the HA docker since configuration.yaml points to it for the doods configuration and it works successfully. But why can’t HA (the generic camera or a simple picture card) read from it?

Thank you

In an effort to greatly simplify this in order to pinpoint the issue, I did the following:

1 - Removed then installed HA docker with the option

-v /share/CACHEDEV1_DATA/Photos/ha-test:/ha-test

2 - Created a new folder and added a random jpg image in it

-rw-r--r-- 1 admin administrators 3912061 2020-02-07 21:22 image.jpg
[/share/CACHEDEV1_DATA/Photos/ha-test] #

3 - Added a Picture card and put /ha-test/image.jpg as the Image path

No edits to any of the configuration files.
Is this setup supposed to show the image?

Note that copying the file to /config/www/image.jpg and using /local/image.jpg as the Picture card path does instantly work

Thanks

did you manage to work it out?

Actually, I did not :frowning:
Maybe it’s sharing issue, a permissions issue, a QNAP NAS specific issue or a docker path issue… Or something else entirely :slight_smile:

It’s definitely something on homeassistant. I tried to load up an image in the shared folder. If I go into the terminal through portainer, I can see the file but homeassistant doesn’t seem to see it.

Maybe a permission thing, I’ll play around a bit more