11

None of the systemd commands are working inside WSL( Ubuntu Bash 18.04). When I ran sudo systemctl is-active kubelet, error is output: System has not been booted with systemd as init system (PID 1). Can't operate. : running command: sudo systemctl is-active kubelet

How to enable systemd feature in WSL? Whats the way to get rid of System has not been booted with systemd

Santosh Hegde
  • 293
  • 2
  • 4
  • 8

4 Answers4

5

cron is a systemd service which you can still run in WSL. See this answer as a guide for how you might setup your kubelet application:

To expand on this link, you can modify Windows startup to load WSL with the background services minimized:

WinEunuuchs2Unix
  • 99,709
  • 34
  • 237
  • 401
3

Nowadays you can try:

sudo service docker start

when using WSL2, if you are running on windows version 2004 or higher (I assume).

0

To run systemd inside WSL2, clone the following repo:

git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git

Run the cloned script:

cd ubuntu-wsl2-systemd-script
bash ubuntu-wsl2-systemd-script.sh

Restart Ubuntu shell then try running the command systemctl to make sure systemd is working.

WMRamadan
  • 103
  • 5
  • This is the same as earlier answer but has content and no link. Since this depends on a script in Github to work, if the link breaks **both this and the other answer** will no longer be useful. Also, this repo is from 2 years ago and not supported. – Danny Varod Nov 15 '22 at 12:21
-1

There is a cool workaround to enable systemd in WSL. Worked for me. Please refer here

Also, for Docker, make sure you have the latest version of it installed and WSL2 is running at least on Windows version 2004. Also make sure to enable WSL2 support in Docker settings.

  • 4
    Link only answers are considered low quality and they become obsolete if the link is changed, moved, or deleted. You should [edit](https://askubuntu.com/posts/1283733/edit) your answer and make sure that the essential parts of your solution are in your answer here. Nobody should actually have to visit any link to understand your solution. https://askubuntu.com/tour – Nmath Oct 14 '20 at 18:25
  • This is the same as later answer with no link. Since this depends on a script in Github to work, if the link breaks **both this and the other answer** will no longer be useful. Also, this repo is from 2 years ago and not supported. – Danny Varod Nov 15 '22 at 12:20