Looks like HA does not support nor want to support using non-root account for HA running in Docker container.
I know it’s already been discussed here:
opened 07:00AM - 05 Dec 24 UTC
closed 01:51PM - 06 Dec 24 UTC
### The problem
After updating to 2024.12, the user setting in my docker-compos… e file leads to a crash while starting homeassistant. I have the user defined like this (which worked for the last year):
```
services:
homeassistant:
container_name: homeassistant
image: "ghcr.io/home-assistant/home-assistant:stable"
user: "1004:100"
volumes:
...
```
When starting up with the 2024.12 update I receive these errors:
```
File "/usr/local/lib/python3.13/getpass.py", line 173, in getuser
~~~~~~~~~~~~~^^
2024-12-05 07:46:40.377 ERROR (MainThread) [root] Uncaught exception
Traceback (most recent call last):
return pwd.getpwuid(os.getuid())[0]
~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'getpwuid(): uid not found: 1004'
The above exception was the direct cause of the following exception:
File "<frozen runpy>", line 88, in _run_code
File "<frozen runpy>", line 198, in _run_module_as_main
File "/usr/src/homeassistant/homeassistant/__main__.py", line 227, in <module>
sys.exit(main())
~~~~^^
File "/usr/src/homeassistant/homeassistant/__main__.py", line 213, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 154, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/asyncio/base_events.py", line 721, in run_until_complete
return future.result()
File "/usr/src/homeassistant/homeassistant/runner.py", line 122, in setup_and_run_hass
hass = await bootstrap.async_setup_hass(runtime_config)
OSError: No username set in the environment
File "/usr/src/homeassistant/homeassistant/helpers/system_info.py", line 73, in async_get_system_info
File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 326, in async_setup_hass
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
await async_from_config_dict(config_dict, hass) is not None
File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 427, in async_load_base_functionality
...<13 lines>...
await async_load_base_functionality(hass)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/bootstrap.py", line 458, in async_from_config_dict
await asyncio.gather(
)
info_object["user"] = cached_get_user()
~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/getpass.py", line 175, in getuser
raise OSError('No username set in the environment') from e
```
This did not occur which prior versions. When removing the user setting, everything works again, but I would really like to keep that this way.
### What version of Home Assistant Core has the issue?
core-2024.12.0
### What was the last working version of Home Assistant Core?
core-2024.11
### What type of installation are you running?
Home Assistant Container
### Integration causing the issue
_No response_
### Link to integration documentation on our website
_No response_
### Diagnostics information
_No response_
### Example YAML snippet
_No response_
### Anything in the logs that might be useful for us?
_No response_
### Additional information
_No response_
But it feels like it the WTH month so…
tmjpugh
(Tmjpugh)
December 6, 2024, 5:54pm
2
Create a homeassistant user:group on the linux host
Provide proper permission to the user:group
set PUID and GUID environment variables for docker container (incomplete compose example below)
I also recommend using mac vlan so you dont need to use host networking
services:
##########################################
# HOMEASSISTANT #
##########################################
hass:
container_name: homeassistant
hostname: homeassistant
mac_address: "02:42:0a:3c:1b:f1"
privileged: false
restart: unless-stopped
stop_grace_period: 10s
depends_on:
- mariadb
image: ghcr.io/ghcr.io/home-assistant/home-assistant:2024.11.0
volumes:
- "/srv/main/docker/homeassistant/application/config:/config"
- "/etc/localtime:/etc/localtime:ro"
ports:
- "8123:8123/tcp" # HA UI
- "20165:21065/tcp" #
- "5353:5353/udp" # mDNS
- "51837:51827/udp" # homekit
environment:
- PUID:"1002"
- GUID:"1002"
networks:
dockerlocal:
esphome:
homeassistant:
reverseproxy:
MacVlan30_Net:
ipv4_address: "10.88.30.15"
EDIT
Never realized non-root was not supported. Yes. please support this.
potelux
(Potelux)
December 6, 2024, 5:55pm
3
The architecture documentation seems pretty clear that this is the intended way to run. HA will not support other setups.
Perhaps you could request using podman instead of docker. Then HA still can require root, but you could have an option to run an unsupported version where you change that.
1 Like
slaamp
December 19, 2024, 10:09pm
4
Should we open another WTH thread to request to be able to run home assistant in Podman or can we use this one?
potelux
(Potelux)
December 19, 2024, 10:11pm
5
You can create a new one. Reference this one and explain why it is different.
Why not use LinuxServer.io image? They add PUID/PGID support for all the images they build. I use their homeassitant image and Nextcloud, over the official ones. Let me know if you guys have concerns about linuxserver.io .
1 Like
francisp
(Francis)
July 16, 2025, 5:12am
7
I do use their SWAG container, can’t complain about that one. Never used their home assistant container.
tmjpugh
(Tmjpugh)
July 16, 2025, 1:22pm
8
I learned that I when setting PGID and PUID don’t work setting user will.
While some containers won’t function with non root user, homeassistant worked without issue for me.
I couldn’t find the dockerfile that Linuxserver.io builds from. I don’t like to use docker containers that I cannot look at.