Skip to content

Savvii/docker-systemd

 
 

Repository files navigation

ghcr.io/savvii/docker-systemd

A Docker image based on ubuntu that runs systemd with a minimal set of services.

This image is meant for development use only. We strongly recommend against running it in production! This image is not tested on WSL, please PR if you did!

Supported tags

  • noble, latest
  • jammy
  • focal

But why?

The short answer: use ghcr.io/savvii/docker-systemd for running applications that need to be run in a full Ubuntu system and not on their own as PID 1.

The long answer: ghcr.io/savvii/docker-systemd might be a better choice than the stock ubuntu image if one of the following is true:

  • You want to test a provisioning or deployment script that configures and starts systemd services.

  • You want to run multiple services in the same container.

  • You want to solve the the PID 1 zombie reaping problem.

If you just want to run a single, short-lived process in a container, you should probably use the stock ubuntu image instead.

Setup (Linux only, skip on Mac)

docker run --rm --privileged -v /:/host ghcr.io/savvii/docker-systemd:noble setup

Running

Run the container:

docker run -d --name systemd --security-opt seccomp=unconfined --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro -t ghcr.io/savvii/docker-systemd:noble

For macOS, use --cgroupns host and :rw:

docker run -d --name systemd --cgroupns host --security-opt seccomp=unconfined --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:rw --platform linux/amd64 -t ghcr.io/savvii/docker-systemd:noble

Testing

This image is useless as it's only meant to serve as a base for your own images, but you can still create a container from it. Run the appropriate command from the sections above.

Check the logs to see if systemd started correctly:

docker logs systemd

If everything worked, the output should look like this:

systemd 255 running in system mode. (+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=hybrid)
Detected virtualization docker.
Detected architecture x86-64.

Welcome to Ubuntu 24.04 LTS!

Set hostname to <container-id>.
Initializing machine ID from random generator.
[  OK  ] Created slice System Slice.
[  OK  ] Reached target Slices.
[  OK  ] Listening on Journal Socket.
[  OK  ] Listening on Journal Socket (/dev/log).
[  OK  ] Reached target Local File Systems.
         Starting Journal Service...
         Starting Create Volatile Files and Directories...
[  OK  ] Reached target Swap.
[  OK  ] Reached target Sockets.
[  OK  ] Reached target Paths.
[  OK  ] Started Create Volatile Files and Directories.
[  OK  ] Started Journal Service.

Also check the journal logs:

docker exec systemd journalctl

The output should show systemd initialization.

To check for clean shutdown, in one terminal run:

docker exec systemd journalctl -f

And in another shut down systemd:

docker stop systemd

The journalctl logs should show a clean shutdown.

Contributors

License

Copyright © 2016-2025 Solita + Savvii. Licensed under the MIT license.

About

systemd-enabled versions of Docker base images

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Dockerfile 53.7%
  • Shell 46.3%