esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 35 forks source link

Docker image does not allow running rootless #2752

Open petrm opened 2 years ago

petrm commented 2 years ago

The problem

The official ESPHome docker image does not allow setting user/group to run the application with. While it is possible to pass to docker username and group, some of the functionality is then broken. The web interface functions, it is possible to edit and save files, but impossible to compile. The compilation fails, because platformio is using for cache /root, which is owned by root and therefore not writable by the user passed to docker. An simple fix would be to use a different folder than /root for the temporary files, for example by setting $HOME to this folder in the docker image or as an ugly workaround chmod /root to RW for all.

Which version of ESPHome has the issue?

2021.11.0

What type of installation are you using?

Docker

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32

Board

N/A

Component causing the issue

Docker image

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

sgofferj commented 2 years ago

I ran into the same issue. It's a potential security issue but also an inconvenience because the yaml files can't be edited by anyone but root. I am using the docker container with a bind mount and would like to make this bind mount available via NFS, so I can edit the files from any computer in my network with a nicer editor.

ilarrain commented 2 years ago

Seems that I've managed to implement a quick fix to make it work:

    environment:
      - 'HOME=/config'
      - 'PLATFORMIO_GLOBALLIB_DIR=/config/.piolibs'

The drawback is that platformio will install required dependencies on compile time.

ptr727 commented 3 months ago

FYI: https://github.com/ptr727/ESPHome-NonRoot