openhab / openhab-docker

Repository for building Docker containers for openHAB
https://www.openhab.org/
Eclipse Public License 2.0
209 stars 128 forks source link

Running on MacOS with podman results in addgroup: unknown group dialout #391

Closed typekpb closed 2 years ago

typekpb commented 2 years ago

running on MacOS, having userid=501 and groupid=20

podman-compose up

with: docker-compose.yml:

version: '3'

services:

  openhab:
    container_name: openhab
    image: "openhab/openhab:3.3.0.M5-alpine"
    restart: always
    volumes:
      - "./openhab/addons:/openhab/addons"
      - "./openhab/conf:/openhab/conf"
      - "./openhab/userdata:/openhab/userdata"
    environment:
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      USER_ID: "501"
      GROUP_ID: "20"
      CRYPTO_POLICY: "unlimited"
    ports:
      - "8080:8080"

results in:

[openhab] | Configuring OpenJDK 11 unlimited strength cryptography policy...
+ IFS='
        '
+ '[' unlimited = unlimited ']'
+ echo 'Configuring OpenJDK 11 unlimited strength cryptography policy...'
+ sed -i 's/^crypto.policy=limited/crypto.policy=unlimited/' /usr/lib/jvm/default-jvm/conf/security/java.security
+ capsh --print
+ grep -E Current:.+,cap_net_admin,cap_net_raw,.+
+ rm -f /openhab/runtime/instances/instance.properties
+ rm -f /openhab/userdata/tmp/instances/instance.properties
+ NEW_USER_ID=501
+ NEW_GROUP_ID=20
+ echo 'Starting with openhab user id: 501 and group id: 20'
+ id -u openhab
[openhab] | Starting with openhab user id: 501 and group id: 20
++ getent group 20
+ '[' -z dialout:x:20:root ']'
++ getent group 20
++ cut -d: -f1
+ [openhab] | Rename group dialout to openhab
group_name=dialout
+ echo 'Rename group dialout to openhab'
+ groupmod --new-name openhab dialout
[openhab] | Create user openhab with id 501
+ echo 'Create user openhab with id 501'
+ adduser -u 501 -D -g '' -h /openhab -G openhab openhab
+ adduser openhab dialout
addgroup: unknown group dialout
exit code: 1
typekpb commented 2 years ago

got it working, using the hint present in: https://www.redhat.com/sysadmin/debug-rootless-podman-mounted-volumes adding flag U to volume mount. For the future reference, following resolves issue reported above for podman rootless on MacOS (however leads to different ones, but that would be investigated separately):

version: '3'

services:

  openhab:
    container_name: openhab
    image: "openhab/openhab:3.2.0-alpine"
    restart: always
    volumes:
      - "./openhab/addons:/openhab/addons:U"
      - "./openhab/conf:/openhab/conf:U"
      - "./openhab/userdata:/openhab/userdata:U"
    environment:
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      CRYPTO_POLICY: "unlimited"
    ports:
      - "8080:8080"