GrepBoard/Manuals
605 manuals ·

Fix "System has not been booted with systemd as init system"

·Tested on Ubuntu 24.04 · systemd 255.4 · nginx 1.24.0 (Docker) · WSL official docs · 2026-10·Test scope ↓·6 steps

systemctl says "System has not been booted with systemd" when PID 1 is not systemd. Start services directly in containers; on WSL, enable it in wsl.conf.

output
System has not been booted with systemd as init system (PID 1). Can't operate.Failed to connect to bus: Host is down

systemctl only sends requests to systemd running as PID 1, so when PID 1 is something else it can do nothing. This is common inside Docker containers and on WSL with systemd disabled. The fix is not systemctl itself but how you start the service.

[1] Check what PID 1 is. If it is not systemd, the error is expected. The container below was started with a shell script, so bash is PID 1.

console
# ps -p 1 -o pid,comm,args    PID COMMAND         COMMAND      1 bash            bash /in.sh# cat /proc/1/commbash

You can also confirm you are in a container. On a real server this prints none.

console
# systemd-detect-virt --containerdocker

[2] Pick the path by where it happens.

EnvironmentPID 1What to do
Docker/Podman containera shell or the image's CMD[3] start the service directly
WSL 2 (systemd off)WSL init[5] enable it in wsl.conf
Real server or VMshould be systemdcheck whether you are inside a chroot or rescue mode

[3] In a container, use service when the package ships an init script. Ubuntu's nginx package installs /etc/init.d/nginx, so this works.

console
# service nginx start * Starting nginx nginx   ...done.# service nginx status * nginx is running

For programs without an init script, run the binary yourself. Test the config first.

console
# nginx -t && nginx && sleep 1 && ps -C nginx -o pid,args && nginx -s stopnginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful    PID COMMAND   3112 nginx: master process nginx

[4] When building an image, make the service the container's main process. Docker's docs define the main process as the ENTRYPOINT and/or CMD at the end of the Dockerfile and recommend one service per container (Docker docs). For nginx, keep it in the foreground with CMD ["nginx", "-g", "daemon off;"] so the container does not exit immediately. If you must run several processes in one container, the same page points to a process manager such as supervisord. If you only need zombie reaping, docker run --init inserts a tiny init as PID 1.

[5] On WSL 2, add the following to /etc/wsl.conf inside the distribution and restart WSL. Per Microsoft's docs, WSL 0.67.6 or newer is required (check with wsl --version), and the current Ubuntu installed by wsl --install already uses systemd by default.

/etc/wsl.conf
[boot]systemd=true

Then run wsl.exe --shutdown from PowerShell on the Windows side to stop all WSL instances. Every open WSL terminal and whatever runs in it ends, so save your work first. Reopen the distribution; systemctl status should show running. The docs add that Debian/Ubuntu need the systemd-sysv package as well as systemd (WSL systemd docs). To revert, set systemd=false or remove the lines and run --shutdown again.

[6] If a service still fails once systemd is running, that is a different problem. Continue with debugging a failed systemd service.

#systemd#systemctl#docker#wsl#pid-1