Before start the installation process, make sure you meet the following prerequisites:
- A Windows 10 operating system with WSL 2 support.
- WSL 2 enabled.
- Ubuntu 22.04 installed on WSL 2.
Close the open terminal on Ubuntu.
Restart WSL via the Windows command line (Powershell).
wsl --shutdown
Access Ubuntu again. Check if Docker was installed correctly on the Ubuntu terminal:
docker --version
You should get a response similar to this:
Docker version 26.1.4, build 5650f9b
To start the Docker service run the following on the Ubuntu terminal:
sudo service docker start
To stop the Docker service run the following on the Ubuntu terminal:
sudo service docker stop
The performance of WSL 2 lies on running everything within Linux,
so avoid running your projects with Docker from the /mnt/c
path, as you will lose performance.
You can open a folder from Ubuntu with Windows Explorer by typing the command on your Ubuntu terminal:
explorer.exe .
The folder will be open using the Windows Explorer.
Remember to navigate to the desired folder on Ubuntu terminal beforehand.
On the Ubuntu terminal confirm that you can access the mounted drive and all its directories using the command below.
sudo ls /mnt/*
You have to see the list of folders and files currently present on your Windows C:/ folder.
If you can see the items just fine, then navigate until the destination folder on the Ubuntu terminal and use the following command.
cp -r /mnt/c/my-folder .
Where "my-folder" is the name of the folder on Windows that you want to copy and "." indicates the destination. Since that we are already on the destination folder we can use just "." , but you can inform the desetination path too.
cp -r /mnt/c/my-folder /home/my-user/my-folder
You can open a project with the IDE Visual Studio Code by typing the command on your Ubuntu terminal:
code .
Remember to navigate to the desired folder on Ubuntu terminal beforehand.
To free cache memory on Linux Ubuntu running on WSL you can use the following command on the Ubuntu terminal:
echo 1 | sudo tee /proc/sys/vm/drop_caches
To access your environment through Windows, I recommend using the Windows Terminal by Microsoft, also available on the Windows Store. This tool includes CLI tabs, a high degree of customization, and even native WSL support to open Linux-based windows.
If you want to see the official documentation, visit https://docs.docker.com/desktop/wsl/
@wcheek
You might want to message that to silva too, this is a fork of his original gist, y'know. I'm not the main dev?
I'd set your /etc/wsl.conf
to
[automount]
enabled = false
[interop]
enabled = false
appendWindowsPath = false
[boot]
command = service docker start
I know it's in the title of the gist, but everyone just make sure you're actually using WSL2. The default is WSL1, so if you need to switch then be sure to do
wsl --install
or if doing things manually follow this guide to upgrade.