How to use systemd in a container?

OS version: Debian Stretch
Docker version: 17.06.2-ce

As the title…

Running systemd in a container is often/usually not recommended. This is a topic that has been discussed a few times in these forums. For a couple of potentially relevant articles, see

here
here

In short, per @dmaze : Systemd does a ton of things, and it's not really appropriate to run inside a Docker container. (It wants to do things like cgroup management that don't make sense; as the blog post you cited suggests, you need to force it to not run every single OS service; and you need to enable the dangerous --privileged option to do it.)

You may want to check out Nestybox; it has developed a container runtime (runc) that enables Docker to deploy containers capable of running Systemd and Docker without using privileged containers. It’s helpful in developer and testing scenarios (e.g., Docker sandboxing, CI/CD, etc.). Check it out here.