MicrosoftDocs / WSL

Source code behind the Windows Subsystem for Linux documentation.
https://docs.microsoft.com/windows/wsl
Other
1.91k stars 578 forks source link

System has not been booted with systemd as init system (PID 1). Can't operate #457

Closed werewolf666 closed 5 years ago

werewolf666 commented 5 years ago

system:win10Pro-1903-18362.239 subLinux:ubuntu1804

when is input 【sudo systemctl start docker】but i can not start docker-daemon ,it show me this:【System has not been booted with systemd as init system (PID 1). Can't operate】 so,is i did wrong?

craigloewen-msft commented 5 years ago

Instead of using sudo systemctl start docker use: sudo /etc/init.d/docker start , as of right now we do not have systemd in WSL 2.

sudocipher commented 5 years ago

The same is not working when trying to start mongodb service.

craigloewen-msft commented 5 years ago

@imdpkmr are you trying to use systemctl? Please try using the mongo equivalent of the command I put above, or sudo service mongod start , does that fix your issue?

cankush625 commented 4 years ago

I have also faced the same issue when I'm using the systemctl command for starting the puppet service.

Instead of that, I had used the service puppet start command on ubuntu and it just worked fine for me. I hope someone gets help from this.

ZhengxunWu commented 4 years ago

I also face the same issue with postgresql. do you have any idea how to solve it? thanks

cankush625 commented 4 years ago

I also face the same issue with postgresql. do you have any idea how to solve it? thanks

@ZhengxunWu Try the command sudo service postgresql start for starting the postgresql service instead of sudo systemctl start postgresql

ZhengxunWu commented 4 years ago

I also face the same issue with postgresql. do you have any idea how to solve it? thanks

@ZhengxunWu Try the command sudo service postgresql start for starting the postgresql service instead of sudo systemctl start postgresql

problem solved.

abmruman commented 4 years ago

Some services like docker (standalone, ubuntu version, installed using bash) still might not run even if you use sudo /etc/init.d/docker start or sudo service docker start or /etc/init.d/docker start.

What you have to do is, run the linux subsystem as administrator by right clicking from start menu. This will solve the issue and sudo service command will execute as it should, as a sudo user.

willyjchen commented 4 years ago

May I ask is there suggested command for systemctl enable equivalent?

ragvri commented 4 years ago

Also one for sudo systemctl daemon-reload?

CoderMonkie commented 4 years ago

Can not start service of firewalld (WSL Ubuntu 18.04.3 LTS)

$ sudo service firewalld start
 * Starting dynamic firewall daemon firewalld                       [ OK ]

$ sudo service firewalld status
 * firewalld is not running

there's no error, but it seems there should be...


$ sudo firewall-cmd --list-ports
FirewallD is not running

$ sudo irewall-cmd --list-services
FirewallD is not running
estape commented 4 years ago

System has not been booted with systemd as init system (PID 1). Can't operate. Failed to talk to init daemon.

I got this when I try to run Anotação 2020-04-18 232009 sudo tasksel

I was try the methodo to install the GUI of Ubuntu.

Joneyao commented 4 years ago

Some services like docker (standalone, ubuntu version, installed using bash) still might not run even if you use sudo /etc/init.d/docker start or sudo service docker start or /etc/init.d/docker start.

What you have to do is, run the linux subsystem as administrator by right clicking from start menu. This will solve the issue and sudo service command will execute as it should, as a sudo user.

it

Some services like docker (standalone, ubuntu version, installed using bash) still might not run even if you use sudo /etc/init.d/docker start or sudo service docker start or /etc/init.d/docker start.

What you have to do is, run the linux subsystem as administrator by right clicking from start menu. This will solve the issue and sudo service command will execute as it should, as a sudo user.

it works for me, run subsystem as administrator, and use 'sudo /etc/init.d/docker start'.

cypherstream commented 4 years ago

I can't upgrade InfluxDB because part of the script in apt-get install influxdb results in an error determining the current runlevel. There are also a lot of other packages that just wont run.

I'm going back to Hyper-V for the time being until you all get it worked out, ok?

danielcinome commented 4 years ago

Es posible que algunos servicios como docker (versión independiente, ubuntu, instalada con bash) aún no se ejecuten, incluso si usa sudo /etc/init.d/docker startor sudo service docker starto /etc/init.d/docker start.

Lo que debe hacer es ejecutar el subsistema de Linux como administrador haciendo clic derecho en el menú de inicio. Esto resolverá el problema y el sudo servicecomando se ejecutará como debería, como usuario de sudo.

Hello, I have followed the steps to solve my problem however this has not worked for me. when I run sudo /etc/init.d/docker start I getsudo: /etc/init.d/docker: command not found. What could I do in that case. Thank you

bisomaticc commented 4 years ago

when I run sudo /etc/init.d/docker start I get sudo: /etc/init.d/docker: command not found. What could I do in that case. same error for me

itechbear commented 4 years ago

when I run sudo /etc/init.d/docker start I get sudo: /etc/init.d/docker: command not found. What could I do in that case. same error for me

Are you using the docker.io package from the official ubuntu repository? If yes, just run

$ sudo dockerd
felipementel commented 4 years ago

I had this problem running WSL 2

the solution was the command

 $ sudo dockerd

Open other terminal and try it

 $ docker ps -a

if after that you still have a problem with permission, run the command:

 $ sudo usermod -aG docker your-user
TheTechOddBug commented 4 years ago

@felipementel Your answer is the most near to solve my problem. I can run docker commands but now I'm getting a "docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:319: getting the final child's pid from pipe caused \"EOF\"": unknown. ERRO[0006] error waiting for container: context canceled". Could you help me with this? Thank you very much in advance for your help.

felipementel commented 4 years ago

Hi @TheTechOddBug ! i think that i can help you, sure!

So, tell me what are you doing to construction this error? And tell me about your environment ...

buildhigh20 commented 4 years ago

it still showing /etc/init.d/docker: command not found.

TheTechOddBug commented 4 years ago

Hi @TheTechOddBug ! i think that i can help you, sure!

So, tell me what are you doing to construction this error? And tell me about your environment ...

Well @felipementel, I upgraded my system to Windows 10 2004, enabled WSL2 and installed an Ubuntu distribution. I set WSL v2 as default. I installed docker inside that Ubuntu distribution and follow your comments to make docker commands work but when I try to run the hello-world simple container with docker run, I got the previously commented error. Again, thank you for your help!

felipementel commented 4 years ago

hi @TheTechOddBug,

check this --> https://success.docker.com/article/error-oci-runtime-create-failed-docker-1809

andremeiras commented 4 years ago
**sudo dockerd**

Thank you Felipe. It worked for me!

Jont828 commented 4 years ago

Is there any equivalent to sudo systemctl enable docker at the moment? I'd like to be able to start the service automatically on boot.

eaglegoboom commented 4 years ago

so how does docker help u fix issues with the System has not been booted with systemd as init system (PID 1), having same issue on kali linux wsl during the setup of openvas, when I do the openvas-setup or the openvas-check-setup gives me that and everything else is running.

MemphisMeng commented 4 years ago

I also face the same issue with postgresql. do you have any idea how to solve it? thanks

@ZhengxunWu Try the command sudo service postgresql start for starting the postgresql service instead of sudo systemctl start postgresql

problem solved.

service is unrecognized in my scenario.

c0x65o commented 4 years ago

For people looking for ways to enable services, I did find this and it was helpful to me https://github.com/shayne/wsl2-hacks/blob/master/README.md

jjxtra commented 4 years ago

Is enabling systemd / systemctl on the roadmap anytime soon? Going back to Ubuntu VM until then...

Biswa96 commented 4 years ago

Recently, there is something added. See my comment here https://github.com/microsoft/WSL/issues/994#issuecomment-698927438

vimalpanchal88 commented 4 years ago

I am also getting this error while i am starting any service in docker debian_10_buster container. Actully i had install debian_10_buster image in docker and i want to restart some services like ntpd, networking, freeswitch using systemctl cmd but it's throwing an error like this. someone can help me to resolve this issue. Error :- System has not been booted with systemd as init system (PID 1). Can't operate. Failed to create bus connection: Host is down

ankitkhalaur commented 4 years ago

@imdpkmr are you trying to use systemctl? Please try using the mongo equivalent of the command I put above, or sudo service mongod start , does that fix your issue? @craigloewen-msft This returns mongod: unrecognized service. I understand that this is because mongodb is not installed yet. But the error in the issue title appears when I try to install mongodb itself. How do I come out of this loop?

achourali commented 4 years ago

May I ask is there suggested command for systemctl enable equivalent?

did you find an equivalent ?

Ravineesh commented 4 years ago

If you are having WSL2, and running Ubuntu on Windows,

In Windows, start the Ubuntu terminal as Administrator then run sudo service docker start

achourali commented 4 years ago

If you are having WSL2, and running Ubuntu on Windows,

In Windows, start the Ubuntu terminal as Administrator then run sudo service docker start

i have docker desktop on windows and wsl2 and ubuntu too i followed what you said but i get this error on ubuntu docker: unrecognized service

linuxadmin25 commented 4 years ago

Hi, I am facing the same issue, and when I'm starting docker service on WS2[Ubuntu Interface], docker service immediately starting and shutting down. This is when I'm trying to reboot the centos image :: System has not been booted with systemd as init system (PID 1). Can't operate.

From Ubuntu Interface :: tanmayroot@DESKTOP-S3H1OVS:/var/tmp/dock$ sudo service docker start [sudo] password for tanmayroot:

Ami missing something? or doing some blunder?

Regards, Tanmay

linuxadmin25 commented 4 years ago

Hi @TheTechOddBug ! i think that i can help you, sure!

So, tell me what are you doing to construction this error? And tell me about your environment ...

I ran sudo dockerd, and i ended up on :: failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.8.4 (legacy): can't initialize iptables table `nat': Table does not exist (do you need to insmod?) Perhaps iptables or your kernel needs to be upgraded. (exit status 3)

Any thoughts to it? PS :: After sudo dockerd, I ran "sudo apt-get update -y".

Ravineesh commented 4 years ago

Hi, I am facing the same issue, and when I'm starting docker service on WS2[Ubuntu Interface], docker service immediately starting and shutting down. This is when I'm trying to reboot the centos image :: System has not been booted with systemd as init system (PID 1). Can't operate.

From Ubuntu Interface :: tanmayroot@DESKTOP-S3H1OVS:/var/tmp/dock$ sudo service docker start [sudo] password for tanmayroot:

  • Starting Docker: docker [ OK ] tanmayroot@DESKTOP-S3H1OVS:/var/tmp/dock$ sudo service docker status
  • Docker is not running

Ami missing something? or doing some blunder?

Regards, Tanmay

Try this, Once the installation of docker is finished, do the following commands in order

  1. sudo groupadd docker
  2. sudo usermod -aG docker 'your_user_name'
  3. su 'your_user_name'
  4. sudo service docker start
  5. docker version (check whether the docker client and server engine is running)

Reference:- https://www.digitalocean.com/community/questions/how-to-fix-docker-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket.

danigrayston commented 3 years ago

Hello, I am having this issue with rpcbind. I'm running Ubuntu 20.04.1 under Windows 10 (WSL2) and am trying to mount a directory in the filesystem. Trying to solve issues with doing this I've realised I can't restart rpcbind from the command line.

$ sudo /etc/init.d/rpcbind start
 * Starting RPC port mapper daemon rpcbind                                                                              ln: failed to create symbolic link '/run/sendsigs.omit.d/rpcbind': No such file or directory
                                                                                                                 [fail]
$ sudo service rpcbind start
 * Starting RPC port mapper daemon rpcbind                                                                              ln: failed to create symbolic link '/run/sendsigs.omit.d/rpcbind': No such file or directory
                                                                                                                 [fail]
$ systemctl start rpcbind
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

In my process list rpcbind shows as: _rpc 1783 266 0 14:47 ? 00:00:00 /sbin/rpcbind -w

Which if I compare to a linux box: root 941 1 0 Nov03 ? 00:00:01 /sbin/rpcbind -f -w

So for some reason rpc isn't a root process, I'm guessing because it's not using systemd. I'm not really familiar with this area and keep going around in circles. Googling so far hasn't bore fruit. Anyone have any ideas?

albasyir commented 3 years ago

systemd still not working until now?

absentm commented 3 years ago

It works on my machine with WSL2:

  1. Install daemonize and fontconfig

    $ sudo apt install -y fontconfig daemonize
  2. Edit /etc/profile

    
    SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd --system-unit=basic.target$' | grep -v unshare | awk '{print $2}')

if [ -z "$SYSTEMD_PID" ]; then sudo /usr/bin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd --system-unit=basic.target$' | grep -v unshare | awk '{print $2}') fi

if [ -n "$SYSTEMD_PID" ] && [ "$SYSTEMD_PID" != "1" ]; then exec sudo /usr/bin/nsenter -t $SYSTEMD_PID -a su - $LOGNAME fi


3. Edit /etc/sudoers 

%sudo ALL=(ALL) NOPASSWD: /usr/sbin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target %sudo ALL=(ALL) NOPASSWD: /usr/bin/nsenter -t [0-9] -a su - [a-zA-Z0-9]


4. Restart WSL2 or source profile

$ sudo source /etc/profile



[Support by Running Snaps on WSL2 (Insiders only for now)](https://forum.snapcraft.io/t/running-snaps-on-wsl2-insiders-only-for-now/13033)
jjxtra commented 3 years ago

sudo: source: command not found

fleetingold commented 3 years ago

It works on my machine with WSL2:

  1. Install daemonize and fontconfig
$ sudo apt install -y fontconfig daemonize
  1. Edit /etc/profile
SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd --system-unit=basic.target$' | grep -v unshare | awk '{print $2}')

if [ -z "$SYSTEMD_PID" ]; then
   sudo /usr/bin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
   SYSTEMD_PID=$(ps -ef | grep '/lib/systemd/systemd --system-unit=basic.target$' | grep -v unshare | awk '{print $2}')
fi

if [ -n "$SYSTEMD_PID" ] && [ "$SYSTEMD_PID" != "1" ]; then
    exec sudo /usr/bin/nsenter -t $SYSTEMD_PID -a su - $LOGNAME
fi
  1. Edit /etc/sudoers
%sudo ALL=(ALL) NOPASSWD: /usr/sbin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
%sudo ALL=(ALL) NOPASSWD: /usr/bin/nsenter -t [0-9]* -a su - [a-zA-Z0-9]*
  1. Restart WSL2 or source profile
$ sudo source /etc/profile

Support by Running Snaps on WSL2 (Insiders only for now)

Yes,it works.I know this from https://kubernetes.io/blog/2020/05/21/wsl-docker-kubernetes-on-the-windows-desktop/#minikube-enabling-systemd same from Daniel Llewellyn.

heidemn commented 3 years ago

The same is not working when trying to start mongodb service.

@imdpkmr @ankitkhalaur I came across this issue, and wrote a SysV init script that allows to start and stop MongoDB without Systemd. Seems to work fine, even after the MongoDB installation with apt-get has returned an error.
In case that it's useful for somebody: https://github.com/heidemn/mongod-sysv

Of course the above-mentioned generic systemd workaround might be the better approach.

maximus-primo commented 3 years ago

I also face the same issue with postgresql. do you have any idea how to solve it? thanks

@ZhengxunWu Try the command sudo service postgresql start for starting the postgresql service instead of sudo systemctl start postgresql

Thank you very much! Worked like a charm <3

prasadpattanshetty commented 3 years ago

Some services like docker (standalone, ubuntu version, installed using bash) still might not run even if you use sudo /etc/init.d/docker start or sudo service docker start or /etc/init.d/docker start.

What you have to do is, run the linux subsystem as administrator by right clicking from start menu. This will solve the issue and sudo service command will execute as it should, as a sudo user.

prasadpattanshetty commented 3 years ago

Thank you very much, This solved my issue.

zkkxu commented 3 years ago

Instead of using sudo systemctl start docker use: sudo /etc/init.d/docker start , as of right now we do not have systemd in WSL 2.

that's great! it works for me

harem234 commented 3 years ago

on WSL2 debian

service --status-all

service memcached status

himalayashinde commented 3 years ago

Some services like docker (standalone, ubuntu version, installed using bash) still might not run even if you use sudo /etc/init.d/docker start or sudo service docker start or /etc/init.d/docker start.

What you have to do is, run the linux subsystem as administrator by right clicking from start menu. This will solve the issue and sudo service command will execute as it should, as a sudo user.

@abmruman Thanks for your valuable comment it helped me to solve my issue for WSL 2 windows ubuntu