Docker run privileged systemd kills all tty sessions

Trying to hunt down the reason for some of my unit tests involving running a privileged Docker container containing systemd out of my terminal sessions I first stumbled upon this this … and then with an improved search this answer to geerlingguy/drupal-vm issue “docker-compose destroys TTY session”.

I could successfully fix this problem based on what user Jasu in the link above reported; now, when building my image, I mask out the following three services/targets:

RUN systemctl mask \
    systemd-logind.service getty.service getty.target

Now, I’m probably even beyond necromancy here to answer a question – what? – 8 years afterwards. But stranger things happen.

2 Likes