I have simple compose file like this:
services:
home-assistant:
container_name: home-assistant
image: homeassistant/armhf-homeassistant:0.84.3
volumes:
- /opt/has/config:/config
- /etc/localtime:/etc/localtime:ro
restart: on-failure
network_mode: host
user: has
I’d like to run this container as user “has” of course, according to specification https://docs.docker.com/compose/compose-file/compose-file-v2/#cpu-and-other-resources all I need is just to set username. But I went into troubles:
root@opi2:/opt/has# docker-compose -f ./docker-compose-hass.yml up -d
Starting home-assistant ...
Starting home-assistant ... error
ERROR: for home-assistant Cannot start service home-assistant: linux spec user: unable to find user has: no matching entries in passwd file
I suppose container does not have user “has” inside /etc/passwd file. So I followed some tips just to set UID:
root@opi2:/opt/has# id -u has
1001
So let put it into compose file: user: 1001
And run docker-compose now:
root@opi2:/opt/has# docker-compose -f ./docker-compose-hass.yml up -d
ERROR: The Compose file '././docker-compose-hass.yml' is invalid because:
services.home-assistant.user contains an invalid type, it should be a string
Ups! Only string is allowed here. How to manage it? Is it possible to use UID somehow in compose file?
OS & installation details
Server: Docker Engine - Community
Engine:
Version: 18.09.0
API version: 1.39 (minimum version 1.12)
Go version: go1.10.4
Git commit: 4d60db4
Built: Wed Nov 7 00:17:57 2018
OS/Arch: linux/arm
Experimental: false
docker-compose version 1.17.1, build unknown
docker-py version: 2.5.1
CPython version: 2.7.15rc1
OpenSSL version: OpenSSL 1.1.0g 2 Nov 2017
Ubuntu 18.04.1 LTS
Linux opi2 4.14.84-sunxi #3 SMP Sat Dec 1 07:18:41 CET 2018 armv7l armv7l armv7l GNU/Linux