Why is it recommended to run WSL2+docker desktop windows, instead of directly install docker on the WSL2 distro ?
It seems that both work but I read that the way to go is with docker desktop, I'm trying to understand why.
Thank you
The docker CLI and UI all work fine from Windows without any additional Linux distros. However for the best developer experience, we recommend installing at least one additional distro and enabling Docker support by: Ensure the distribution runs in WSL 2 mode. WSL can run distributions in both v1 or v2 mode.
No you do not require Docker Desktop to use WSL 2. The only requirements for WSL 2 are that you: Have the right version of Windows installed. Have the Virtual Machine Platform and Windows Subsystem for Linux optional components installed.
You are able to run docker in WSL without Docker Desktop.
Docker Desktop for Windows provides a development environment for building, shipping, and running dockerized apps. By enabling the WSL 2 based engine, you can run both Linux and Windows containers in Docker Desktop on the same machine.
The main difference between using Docker Desktop with the WSL2 integration and using docker directly in WSL2 without Docker Desktop is the level of integration with your tools.
When you use Docker desktop, you have access to docker in powershell/cmd, have access to your file on windows, the possibility to switch to Windows container and to use it with your IDE.
If you install docker inside your WSL2 distro, docker will not be accessible from Windows directly.
Although all the benefits pointed out in approved answer sound interesting. I recommend to use docker-ce inside WSL directly instead of Docker for Desktop. It's too buggy at the moment.
Even when all the issues had been reported a long time ago. You will often encounter issues losing connection between Windows browser to WSL or connection between your app running inside WSL to Docker for Desktop. Another common issue if shutting down Windows when having Docker desktop is annoying also:
com.docker.wsl-distro-proxy.exe - Application Error
The application was unable to start correctly (0xc0000142).
To be concluded, working with Docker for Desktop Windows is a pain atm.
Differences between Docker Desktop in Windows and Docker Engine (CE) in a WSL2 instance. Some of these are repeated in other answers, many are not:
Adds additional features such as:
docker-desktop
instance is available to all shells (WSL shells, PowerShell, and CMD.The Docker daemon from the Docker Desktop installation be accessed from multiple WSL2 instances, PowerShell, and CMD.
Still uses WSL2 by default. docker-desktop
and docker-desktop-data
WSL instances are created. A single Docker Engine is installed in docker-desktop
which is then exposed to the other WSL2 instances. For instance, running ls $(command -v docker)
in Ubuntu will show that /usr/bin/docker
is a symlink to /mnt/wsl/docker-desktop/cli-tools/usr/bin/docker
, and Docker sockets to access the daemon are injected into /var/run
in each WSL instance.
Can alternatively use a Hyper-V backend on Windows Pro and higher if WSL2 is not able to run on the system.
Images, containers, volumes, etc. are contained in the docker-desktop-data
WSL2 distribution, which is not directly accessible. Use standard docker
commands to export and move data, as is the best practice.
Value-added features (over and above Docker Engine and K8S) are closed-source
Corporate use requires a paid license (currently starting at $5/month) (see footnote)
Seems to track the open-source releases fairly closely, although I haven't paid that much attention to how much time elapses between when a CE release is incorporated into Desktop.
As far as I know, there's no way to decouple the Docker Engine release from that of Docker Desktop, so there's no way to rollback to an earlier CE release on the system if needed.
Can be installed directly into most any WSL2 distribution, as long as that distribution would support Docker Engine in the first place. In other words, while you can create a very basic BusyBox distribution for WSL2 (I've done it), you wouldn't be able to run Docker in it without adding additional dependencies. Most major, full-featured distributions, of course, will have no problem.
Open-source
Kubernetes must be configured separately
Installation requires more in-depth Linux knowledge, along with an understanding of the differences in WSL. For instance, the Docker docs assume Systemd is available and that the package manager starts Docker as soon as it is installed. That isn't the case on WSL2.
Images, containers, volumes, etc. are placed in the WSL2 distro into which you've installed CE.
Many of the Docker Desktop features can be replicated using the CE version, but it requires manual effort. For instance, there's no reason that you can't create the same type of "shared" environment that can be made available to other WSL2 instances, if you put in the effort.
Can always install any release desired, and different WSL2 distributions on your computer can have different Docker Engine/CE releases if needed.
Note that I have no relation to nor financial interest in Docker.
Most users will be best served by Docker Desktop. The pre-integration alone is a timesaver that pays for itself. Windows users who may be less familiar with Linux should almost certainly opt for the Desktop version.
I know the paid model always seems to upset some in the community, but I'd encourage those that do require a paid license to consider:
At $60/year, if Docker Desktop saves you even a half hour of time over having to configure Docker Engine, it has likely paid for itself. Not that you make $120/hour (or maybe you do), but your employer expects you to generate productivity at least in that range. Your employer would typically rather pay for tools that make you more productive than having you roll-your-own.
If you believe Docker is a worthwhile tool for your organization, then financial support which allows for its continued development and maintenance is also beneficial for your company.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With