I wanted to add a user in my Dockerfile, but when I do systemctl doesn’t work correctly. Here’s a minimal example:
FROM resin/%%RESIN_MACHINE_NAME%%-debian:latest
ENV INITSYSTEM on
RUN adduser --disabled-password --quiet --gecos “test” test
RUN usermod --append --groups sudo test
RUN printf “test:test” | chpasswdUSER test
WORKDIR /home/test
Then when I open the terminal and trying using systemctl, I get
test@d704d16:~$ sudo systemctl
…
Failed to get D-Bus connection: Unknown error -1
Yet when I comment out all the new user lines, it works as expected.