Home > Net >  bash on windows cannot find any command from path
bash on windows cannot find any command from path

Time:02-13

I am trying to execute a bash script on windows (with WSL 1). This script contains a call to a command, like following:

script.sh

docker --version

after execute it from command line: bash script.sh

it returns "command not found". Also with any command included in the windows PATH, I've got the same result.

Cany anybody help me to know what I am doing wrong?

Thank you so much in adavance.

CodePudding user response:

A couple of problems:

  • First, you don't mention whether you have Docker installed or not. If you don't, then there are two different ways to install Docker with WSL -- Docker Desktop and Docker Engine. See my answer here for the differences. As I state in that answer, I recommend Docker Desktop.

  • But note that Docker only works in WSL2 due to the fact that it requires a real Linux kernel. You mention that you are using WSL1. If you are on a system which supports virtualization, you can enable WSL2 by following steps 2-5 of the manual installation guide, then converting your WSL1 instance to WSL2 with:

    wsl --set-version <distroname> 2
    

    You can then proceed with enabling Docker in your WSL2 instance.

CodePudding user response:

Isn't it obvious , you don't have docker installed on your wsl system, if you are confused then let me clear one thing wsl provides you a complete different environment so your windows programs aren't going to work on wsl it has it's own seperate folder

Solution

if you want it to work then you have to install docker again but on your wsl , You can do it by following commands (assuming you are using any latest debian)

sudo apt-get install docker.io
  • Related