Instalando Docker em um WSL 2 com Ubuntu 22.04
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/
Working solely in wsl is the ideal workflow.
But to move or copy paste files, usually autompint automount* is easier than manual setup.
Move or copy are fine.
Just don't do something like wet wget* across system.
If you got unlimited internet data with FUP. There are syncthing and its forks for copy paste or mirrored files/notes.
I'll share my personal .conf and wsl.config later when I get to open my pc at home.
It depends on the user needs.
One could also min max the values in umask etc. For beginner I mainly just use default.
I forgot to synced my wsl configs using syncthing so it's only in my pc, rn.
Also, since I haven't got the time to fully deploy docker, my configs are mainly for wsl and distro.
There's something like loop address for docker but I only find it in issue not yet in practice. ( I was researching each confs that have to do with docker.)
I was doing wsl DE GUI to set up waydroid, but the kernel also stop me from doing it.
There's also a drop cache problem in wsl if it's set to auto.
Links:
https://gist.github.com/gorshkov-leonid/b55072d6876acecf43dabaf7f1e72cf0
https://gist.github.com/martinsam16/4492957e3bbea34046f2c8b49c3e5ac0
(Anyone are free to chime in for docker wsl configs optimization, I only know some optimization for wsl case. Docker wsl configs are in my waitlist but not priority;
since I only intend to taste Linux dev env in wsl, but was intrigued by andro emu in linux as an OS alt to proprietary windows andro emu)
Edit misspellings
edit 2:
Yeah, old wsl.conf
Sadly my wsl.conf is inside a wsl.vhdx backup.
Interop better be off indeed. Not sure about vscode integration but, I haven't reached that part yet.
I think having a text editor or DE inside wsl is better, I don't know yet how to access wsl things from Windows vscode integration.
There's a devops oriented distro, but I'm not sure if Linux ISOs need just to be tar'd so that it could be imported into wsl. Or it's more complex than that.
Edit:
I got the name now: bluefin
https://news.ycombinator.com/item?id=38992292