Running systemd inside a Centos 8 Docker container

Support for systemd in Docker has improved a lot since this 2016 article, but it’s still not obvious quite how to make it work. Why would you want this? Mostly for testing full-server deploys (for example we test ansible deployments against various docker containers to ensure there are no bugs).

Here’s a systemd-based centos 8 Dockerfile that also includes an ssh server:

You can then launch this like:

For the latest centos 7 you can use the following Dockerfile:

Leave a Reply

Your email address will not be published. Required fields are marked *