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/
Thank you!
You are welcome.
Very nice, thanks
Very nice, thanks
You are welcome.
Thank you!
Thank you!
You are welcome.
Thanks a lot!
Thanks for sharing this. It's really helpful.
Thanks a lot!
You are welcome.
Thanks for sharing this. It's really helpful.
You are welcome.
I want to know how to move Ubuntu and Docker to another drive, because I don't have space on my C drive.
I want to know how to move Ubuntu and Docker to another drive, because I don't have space on my C drive.
Hello. I never done this kind of drive migration before. However I found these two articles about the matter:
Maybe the information there can help you ?
It appears that WSL has some commands to help you on the migration process, but, again, I never done this before and I don`t know if it will work.
Good luck.
I want to know how to move Ubuntu and Docker to another drive, because I don't have space on my C drive.
Hello. I never done this kind of drive migration before. However I found these two articles about the matter:
- https://medium.com/@rahmanazhar/move-wsl-to-another-drive-ab8002152cf2
- https://blog.iany.me/2020/06/move-wsl-to-another-drive/
Maybe the information there can help you ?
It appears that WSL has some commands to help you on the migration process, but, again, I never done this before and I don`t know if it will work.
Good luck.
This is cool. Thanks.
Thank you
I actually need that since Vanilla OS requirement is pretty high on disk space. I learnt of export import from TroubleChute video. I will have to check the actual .vhdx on the environment path tho, by using diskpart.
Oh yeah, I first found this from the sparse feature issue in wsl, that lead me to diskpart feature, and eventually export import feature.
I was researching backup option in linux, but since wsl is a vm, turns out export import is more than enough instead of foxclone or timeshift.
For reducing disk space, backup, and moving the wsl .vhdx VM file, links:
https://superuser.com/questions/1606213/how-do-i-get-back-unused-disk-space-from-ubuntu-on-wsl2
Thanks for the notif tho, now I will check my .vhdx to use other distro and move it to other disk. I do hope the imported .vhdx doesn't resides in windowsapp/Ubuntu directory anymore which is on C:
Thank you
You are welcome.
I actually need that since Vanilla OS requirement is pretty high on disk space. I learnt of export import from TroubleChute video. I will have to check the actual .vhdx on the environment path tho, by using diskpart.
Oh yeah, I first found this from the sparse feature issue in wsl, that lead me to diskpart feature, and eventually export import feature.
I was researching backup option in linux, but since wsl is a vm, turns out export import is more than enough instead of foxclone or timeshift.
For reducing disk space, backup, and moving the wsl .vhdx VM file, links: https://superuser.com/questions/1606213/how-do-i-get-back-unused-disk-space-from-ubuntu-on-wsl2
Thanks for the notif tho, now I will check my .vhdx to use other distro and move it to other disk. I do hope the imported .vhdx doesn't resides in windowsapp/Ubuntu directory anymore which is on C:
Thanks for sharing.
Export, import is still my way to go.
There's another option by the same YTber, using junction, though I would say this is for advance user only since hardlink symbolic link and junction have their differences in use case.
There's a good chart of this in ss64 website.
So I still prefer --export --vhdx and other options
Then --import.
The diskpart program made by one of the user in that github issue is nice too, since it pings the .vhdx file location
This is the link to the backup solution (if some users can't find it because of YT search being dependent on keyword), I just found it today there's a junction option if you search 'backup' or 'move data':
https://youtu.be/-R4VcMCkc6k
(It's fast in my m2 SSD, it would probably be slower in HDD)
Edit:
Spellings, wordings.
Thank you! Great content!
Thank you! Great content!
You are welcome.
You rock !! thank you ;) ...
Thank You!
thanks
You rock !! thank you ;) ...
You are welcome.
Thank You!
You are welcome.
thanks
You are welcome.
Thank you!