How to run Docker commands in CMD/PowerShell powered by Docker running in WSL2


In the last tutorial, we learned how to create Docker images without Docker Desktop in Windows. However, However, this can break our daily duties, especially if we have automated anything. This can be fixed in three steps:

1) Start Docker in Ubuntu using:

sudo dockerd

2) Open a new CMD/PowerShell window without closing the Ubuntu one.

3) Add the prefix wsl before every docker command and run them.

wsl docker --version
wsl docker --help


And that's all. You can find other tutorials on how to remove the prefix, but this is the easiest and fastest option.

Comments