WSL normally will never ask for a password when starting up Ubuntu or any other distribution. From the looks of it, you may have a sudo <command>
in one of your shell startup files. Perhaps you are trying to sudo service start docker
or something similar?
Try going to PowerShell and running wsl ~ -e bash --noprofile --norc
. This will start Ubuntu, run Bash as the shell, but tell it not to process the startup files.
I'm assuming that you'll be able to start without it asking for a password, but if not we'll keep troubleshooting that part.
If it does startup without a password, then examine your ~/.bashrc
for a sudo
command. Remove it if you find it. Other candidates includes ~/.bash_profile
or ~/.profile
, but the rc file is the likeliest candidate.
If you are trying to start Docker (since you mention it in the question), there are three better options:
Docker Desktop is pre-integrated with WSL and will likely alleviate most of your configuration pain. This is the preferred way to run Docker under WSL.
Under WSL, you can start services as root without requiring sudo
by placing them in your /etc/wsl.conf
as mentioned in my Super User answer on the topic.
You can now start services via Systemd if desired by using the latest WSL version as noted in this answer.