Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
werewolf666 opened this issue Jul 15, 2019 · 84 comments

Comments

@werewolf666
Copy link

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
Copy link
Collaborator

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
Copy link

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

@craigloewen-msft
Copy link
Collaborator

@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
Copy link

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
Copy link

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

@cankush625
Copy link

cankush625 commented Nov 18, 2019

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
Copy link

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
Copy link

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
Copy link

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

@ragvri
Copy link

ragvri commented Mar 27, 2020

Also one for sudo systemctl daemon-reload?

@CoderMonkie
Copy link

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
Copy link

estape commented Apr 19, 2020

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
Copy link

Joneyao commented May 7, 2020

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
Copy link

cypherstream commented May 20, 2020

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
Copy link

danielcinome commented May 21, 2020

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 get sudo: /etc/init.d/docker: command not found. What could I do in that case. Thank you

@bisomaticc
Copy link

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
Copy link

itechbear commented May 30, 2020

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
Copy link

felipementel commented Jun 11, 2020

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
Copy link

@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
Copy link

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
Copy link

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

@TheTechOddBug
Copy link

TheTechOddBug commented Jun 16, 2020

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
Copy link

@andremeiras
Copy link

**sudo dockerd**

Thank you Felipe. It worked for me!

@Jont828
Copy link

Jont828 commented Jul 30, 2020

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
Copy link

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
Copy link

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
Copy link

c0x65o commented Sep 14, 2020

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

@Saurabhdaswant
Copy link

sudo /etc/init.d/docker start

i did this with mongod but it said : sudo: /etc/init.d/mongod: command not found

@Saurabhdaswant
Copy link

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.

i used this for mongod but intead i got this error : mongod: unrecognized service

@Saurabhdaswant
Copy link

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'.

again i got this error : sudo: /etc/init.d/mongod: command not found

@craigloewen-msft
Copy link
Collaborator

@Saurabhdaswant mongo doesn't include a /etc/init.d/mongod script by default. But here are docs on how to do this:
https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-database#add-the-init-script-to-start-mongodb-as-a-service

@thewackyindian
Copy link

@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

I am having the same issue:
I used this documentation to install Mongodb on my WSl on windows 10 👇
https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-database#install-mongodb

Here after running Step 6: Install MongoDB packages: sudo apt-get install -y mongodb-org on my terminal
It ran good but gave this error:
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
invoke-rc.d: could not determine current runlevel

and after running Step 10: Run a Mongo instance: sudo mongod --dbpath ~/data/db
it showed me a bunch of these but you can read the last line it says exit code 100.👇
https://ibb.co/2ZT273r (Important image please see).
I even ran Step 11:Check to see that your MongoDB instance is running with: ps -e | grep 'mongod'
but it gave no output .

In a nutshell please help me with some valid resources or help to install mongodb on wsl2 and run it smoothly.

PS:I ran with all helps from StackOverflow to github and dev , from changing ownerships to running init scripts but the
everytime I run:
sudo service mongodb start
or any related commands it says {fail].

So please look into this !

@heidemn
Copy link

heidemn commented Aug 28, 2021

@thewackyindian @gaur-abhi524 Find here a script for the full installation of MongoDB 4.0 or 5.0 in WSL2, Ubuntu 20.04:
https://github.com/heidemn/mongod-sysv#full-installation-of-mongodb

@Mayor294
Copy link

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

Am having this issue now in my termux 🤦🏽‍♂️🤦🏽‍♂️🤦🏽‍♂️ how can i solve this?

@vimalpanchal88
Copy link

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

Am having this issue now in my termux 🤦🏽‍♂️🤦🏽‍♂️🤦🏽‍♂️ how can i solve this

Use:-

docker container run -d --hostname --name privileged=true <image_name> /sbin/init

@d1mnewz
Copy link

d1mnewz commented Sep 27, 2021

If you wish to run systemctl, there is a way for it in WSL2. You can follow the gist https://gist.github.com/djfdyuruiry/6720faa3f9fc59bfdf6284ee1f41f950

@AllanOricil
Copy link

For some reason, my WSL has not been updated to 2, and my windows build is 19043. Can anyone help me to know how I can do it? I have already tried to set the default version to 2, downloaded a new image, but it started on version 1. I already tried to convert an image to version 2, it says it will take a while, but it actully did nothing.

@oonsamyi
Copy link

oonsamyi commented Jan 16, 2022

@Saurabhdaswant mongo doesn't include a /etc/init.d/mongod script by default. But here are docs on how to do this: https://docs.microsoft.com/en-us/windows/wsl/tutorials/wsl-database#add-the-init-script-to-start-mongodb-as-a-service

It helped usage mongo on WSL2. Thank you!

@alifarabi
Copy link

if you use wsl, at first please be sure you run docker windows and then try wsl for docker command

@thenrique88
Copy link

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.

March, 2022. Your answer helped me! Worked for me!

@ycllz
Copy link

ycllz commented Mar 10, 2022 via email

@jerrychong25
Copy link

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.

Thanks @craigloewen-msft !

@ycllz
Copy link

ycllz commented Apr 15, 2022 via email

@franciskinyuru
Copy link

I have deployed a flask application on wsl 20.04.4, create the service under /etc/systemd/system but the command

sudo service myservice

start does not work
Also the service not in the /etc/init.d since have created it myself

@doncadavona
Copy link

How do we manage timezones in WSL 2 Ubuntu 22.04?

$ timedatectl

Getting this error:

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

@felipetssilva
Copy link

I was trying to install k3s on wsl and was running into this issue....

Simply execute /etc/init.d$ curl -sfL https://get.k3s.io | sudo bash - (from /etc/init.d ) and it works like magic!!!

@jayaprakash369
Copy link

jayaprakash369 commented Oct 27, 2022

I can't start the snapd service also without systemctl. there is no init file in /etc/init.d directory so cant use /etc/init.d/snapd start. what can I do to start the snapd service in wsl2?

@DanielAKAOi
Copy link

DanielAKAOi commented Nov 7, 2022

try:

update-alternatives --config iptables > type "1" > "enter"

====================
#######################
====================

┌──(root㉿darkside)-[~]
└─# update-alternatives --config iptables
There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).

Selection Path Priority Status

*0 /usr/sbin/iptables-nft 20 auto mode
1 /usr/sbin/iptables-legacy 10 manual mode
2 /usr/sbin/iptables-nft 20 manual mode

Press to keep the current choice[*], or type selection number: 1

######## RESTART WSL SERVICE ########

┌──(root㉿darkside)-[~]
└─# update-alternatives --config iptables
There are 2 choices for the alternative iptables (providing /usr/sbin/iptables).

Selection Path Priority Status

0 /usr/sbin/iptables-nft 20 auto mode
*1 /usr/sbin/iptables-legacy 10 manual mode
2 /usr/sbin/iptables-nft 20 manual mode

Press to keep the current choice[*], or type selection number: 1

┌──(root㉿darkside)-[~]
└─# /etc/init.d/docker start

┌──(root㉿darkside)-[~]
└─# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b770f6f2e0f3 nginx:alpine "/docker-entrypoint.…" 6 months ago Up Less than a second 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp rengine_proxy_1
169d47efc1eb peterdavehello/tor-socks-proxy "/usr/bin/tor -f /et…" 6 months ago Up Less than a second (health: starting) 8853/udp, 9150/tcp rengine_tor_1
7ad0a5db13bc docker.pkg.github.com/yogeshojha/rengine/rengine:latest "/usr/src/app/entryp…" 6 months ago Up Less than a second 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp rengine_web_1
94bbfec90492 rengine_celery "/usr/src/app/celery…" 6 months ago Up Less than a second rengine_celery_1
1d6e19307810 postgres:12.3-alpine

====================
#######################
====================

@SeniorSupportEngineer
Copy link

DanielAKAOi that worked for me thank you

@liudonghua123
Copy link

I have the same problems recently, I update the /etc/wsl.conf (append the following configures) and the restart wsl via wsl --shutdown.

[boot]
systemd=true

I also checked the process name of pid 1.

liudonghua@DESKTOP-DELL:~$ ps -ef|more
UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  0 15:12 ?        00:00:00 /sbin/init
root           2       1  0 15:12 ?        00:00:00 /init
root           5       2  0 15:12 ?        00:00:00 plan9 --control-socket 6 --log-level 4 --server-fd 7 --pipe-fd 9 --
log-truncate
root          75       1  0 15:12 ?        00:00:00 /lib/systemd/systemd-journald
root         103       1  0 15:12 ?        00:00:00 /lib/systemd/systemd-udevd
root         116       1  0 15:12 ?        00:00:00 snapfuse /var/lib/snapd/snaps/lxd_22923.snap /snap/lxd/22923 -o ro,
nodev,allow_other,suid
root         117       1  0 15:12 ?        00:00:00 snapfuse /var/lib/snapd/snaps/snapd_15534.snap /snap/snapd/15534 -o
 ro,nodev,allow_other,suid
root         118       1  0 15:12 ?        00:00:00 snapfuse /var/lib/snapd/snaps/core20_1405.snap /snap/core20/1405 -o
 ro,nodev,allow_other,suid
systemd+     141       1  0 15:12 ?        00:00:00 /lib/systemd/systemd-networkd
systemd+     303       1  0 15:12 ?        00:00:00 /lib/systemd/systemd-resolved
......

Although the process of pid 1 is not systemd, I found some systemd related process. and some daemons like redis worked then.

@ghost
Copy link

ghost commented Jan 22, 2023

I've enabled systemd in WSL per https://learn.microsoft.com/en-us/windows/wsl/wsl-config instructions. wsl --shutdown executed. I'm getting this:

$ cat /etc/wsl.conf
[automount]
enabled = false

[network]
generateResolvConf = false

[boot]
systemd = true

$ sudo systemctl start docker.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

$

SOLVED: After running wsl --update and restarting WSL.

@SeniorSupportEngineer
Copy link

SeniorSupportEngineer commented Jan 23, 2023

wsl --update solved allot of problems,
Only the mtu of my vpn is different, so I have to run "sudo ifconfig eth0 mtu 1350"
now I can access internet over vpn connection.
But when I start a docker container, inside the container I still don't have internet.
There I found the solution in docker-compose.yml

networks:
default:
driver: bridge
driver_opts:
com.docker.network.driver.mtu: 1350

@sevi-kun
Copy link

For people looking at this down the road:
Systemd support is now available in WSL!

@TofuWand
Copy link

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.

In Termux, I got this:
/etc/init.d/docker: 86: ulimit: error setting limit (Operation not permitted)

@TofuWand
Copy link

I've enabled systemd in WSL per https://learn.microsoft.com/en-us/windows/wsl/wsl-config instructions. wsl --shutdown executed. I'm getting this:

$ cat /etc/wsl.conf
[automount]
enabled = false

[network]
generateResolvConf = false

[boot]
systemd = true

$ sudo systemctl start docker.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

$

SOLVED: After running wsl --update and restarting WSL.

Nice, but this doesn't work in Termux.p, unfortunately so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests