"System has not been booted with systemd as init system": WSL, containers, and what to run instead
Fix "System has not been booted with systemd as init system (PID 1). Can't operate": turn systemd on in WSL, or run services without systemctl inside Docker containers.
by OhSudo ··
Checked on real software: Ubuntu 24.04, systemd · November 2026How we check
$ sudo systemctl start nginxSystem has not been booted with systemd as init system (PID 1). Can't operate.Failed to connect to bus: Host is downsystemctl only talks to systemd, and systemd isn’t running here. On a normal Linux server, systemd is the first process, number 1, and it starts everything else. Here something else is process 1, so there’s nobody for systemctl to talk to.
That happens in two places: WSL, where systemd is off unless you turn it on, and containers, where the container’s own program is process 1.
- systemctlwants to talk to systemdfinds(fails)
- PID 1not systemd: WSL, a container(breaks here)so
- Can't operateFailed to connect to bus
TL;DR
See what’s running as process 1:
ps -p 1 -o comm=initin WSL: turn systemd on, as in section 2.- Anything else in a container: don’t use
systemctlthere, and run the program directly, as in section 3.
1. Which situation are you in?
ps -p 1 -o comm=| You see | Where | Fix |
|---|---|---|
systemd |
A normal system | This error shouldn’t appear. Check you’re not in a chroot |
init |
WSL with systemd off | Section 2 |
bash, sh, node, nginx, … |
A container | Section 3 |
2. WSL: turn systemd on
Recent versions of WSL support systemd, and new Ubuntu installs have it on. For an older install, add this to /etc/wsl.conf inside the distribution:
[boot]systemd=trueThen restart WSL, from PowerShell or Command Prompt on Windows:
wsl --shutdownOpen the distribution again, and check:
ps -p 1 -o comm=systemctl statusIt needs WSL 0.67.6 or later: wsl --version shows yours, and wsl --update updates it. If you’re doing this to run Docker inside WSL, Cannot connect to the Docker daemon covers that case, including Docker Desktop’s integration.
Without systemd, many services can still be started with their old-style scripts, which don’t need it:
sudo service nginx startsudo service --status-all3. Containers: run the program itself
A container is meant to run one program, as process 1, in the foreground. That’s what keeps the container alive, and what Docker watches and restarts. So instead of systemctl start nginx in a Dockerfile or a script, start the program directly:
FROM nginx:1.27# nginx's image already does this:CMD ["nginx", "-g", "daemon off;"]| Instead of | In a container |
|---|---|
systemctl start nginx |
nginx -g 'daemon off;' as the command |
systemctl start php8.3-fpm |
php-fpm8.3 -F |
systemctl start redis |
redis-server |
systemctl enable ... |
Nothing: the container’s command is what runs |
| Several services | One container each, with Docker Compose |
The official images for most software already run their program this way, so often the fix is to use one. The Dockerfile Generator starts from them.
A package’s install script may call systemctl and print this error while installing in a Dockerfile. It’s usually harmless there, as the service isn’t meant to start during the build.
If you really need systemd in a container, for example to test unit files, Podman supports it directly with podman run --systemd=always. With Docker, it needs extra settings, and it’s rarely worth it: a virtual machine is the better fit.
4. A related message: the user bus
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)This one comes from systemctl --user, when there’s no login session for that user, for example after su or sudo -u. Older versions say No medium found instead. Log in as that user over SSH, or do what the message suggests: systemctl --user -M user@ status. Services that should run without anyone logged in need sudo loginctl enable-linger user.
5. Once systemd runs
Your services can then be managed the normal way. To write a unit file for your own program, use the systemd Unit Generator. If one won’t start, see Job for service failed.
Warning
Don’t install “fake systemctl” scripts from the internet to silence this. They imitate systemctl with their own logic, and behave differently from the real thing, which makes later problems harder to understand. In a container, run the program directly. In WSL, turn on the real systemd.
Shell, we have a problem!
Similar, but different: Running in chroot, ignoring command means you’re in a chroot, for example while repairing a system from a live USB, where systemd isn’t in charge. Unit nginx.service not found means systemd runs, and the service isn’t installed. Cannot connect to the Docker daemon is Docker’s own version of a service that isn’t running.
Found this useful? Share it.
Found a mistake? Let us know at contact@ohsudo.com.