For some commercial reasons, I am no longer allowed to use Docker Desktop on my company's computer. However, I installed the Windows Subsystem for Linux (WSL) for using Docker commands directly within the WSL, and it's working fine when typing "wsl" on my cmd and then "docker":
It works also when typing the full command using "wsl" prefix inside my cmd, like this :
wsl /snap/bin/docker
So I tried to create an alias using DOSKEY, like this:
doskey docker=wsl /snap/bin/docker
For a more convenient use.
But when I try to execute Docker commands with my new alias, it only shows me the manual and nothing else, no matter the argument:
C:\Users\myUser>docker image ls
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options: <All the options and commands available in the manual when typing "docker">
What am I doing wrong?
The solution was simple, doskey does not accept arguments ^^ So I created a .cmd script called "docker.cmd" written like this :
And then I put this file in my System32 folder (it works with any other folder in the PATH environment variable, I put it in System32 just for the test). The %* allows me to put arguments, and now my command works fine. Not really an alias, but it's doing the job.
But this script raises another problem, detailed in this question : WSL Docker with Windows : Docker Daemon not started when typing commands with custom script