Skip to content

Commit d2e1527

Browse files
committed
feat: Add Docker Engine and Docker Desktop compatibility information and more info about WSL sparse mode
1 parent ad49961 commit d2e1527

File tree

2 files changed

+64
-8
lines changed

2 files changed

+64
-8
lines changed

README.en.md

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
* [Can I access applications running in WSL 2 from Windows?](#can-i-access-applications-running-in-wsl-2-from-windows)
103103
* [Can I run graphical applications in WSL 2?](#can-i-run-graphical-applications-in-wsl-2)
104104
* [Can I use WSL in production scenarios?](#can-i-use-wsl-in-production-scenarios)
105-
105+
* [Can I run Docker Engine alongside Docker Desktop?](#can-i-run-docker-engine-alongside-docker-desktop)
106106

107107

108108
</details>
@@ -667,25 +667,53 @@ Typically, VHDX files are saved in `C:\Users\<your_user>\AppData\Local\Packages\
667667
668668
### Compressing the WSL 2 Virtual Disk
669669
670-
The WSL 2 virtual disk is a VHDX file that grows as you use Linux. If you delete files, the virtual disk does not automatically shrink; it will retain its size.
670+
The WSL 2 virtual disk is a VHDX file that grows as you use Linux. If you delete files, the virtual disk does not automatically shrink; it will remain the same size.
671671
672-
To reduce the size, enable the `sparse` mode in WSL 2, which is automatic virtual disk compression. To enable it, edit the `.wslconfig` file:
672+
To reduce its size, enable the `sparse` mode in WSL 2, which provides automatic disk compression. To enable it, edit the `.wslconfig` file:
673673
674674
```conf
675675
[wsl2]
676676
sparseVhd=true
677677
```
678678
679-
This option only applies to new virtual disks. For existing virtual disks, run the command:
679+
This option will only apply to new virtual disks.
680+
681+
For existing virtual disks, use the following commands:
680682
681683
```bash
682684
wsl --manage "Ubuntu" --set-sparse true
683685
wsl --manage "docker-desktop" --set-sparse true # If using Docker Desktop
684686
```
685687
686-
This will convert the virtual disk to sparse mode, enabling automatic compression.
688+
This will convert the virtual disk to sparse mode, which is automatic disk compression.
689+
690+
Before running the command, make sure the Linux distribution is stopped by using `wsl --shutdown` to stop all distributions.
691+
692+
If you have an old distribution and after applying sparse mode the virtual disk hasn't reduced in size, you can compress it manually.
693+
694+
Use the [wslcompact](https://github.com/okibcn/wslcompact) tool for this process. This tool is an executable for `PowerShell` that exports and imports the virtual disk, forcing WSL to compress it.
695+
696+
Run the command:
697+
698+
```bash
699+
wslcompact -c Ubuntu
700+
```
701+
702+
This will generate a new virtual disk named `ext4.vhdx`, which will be your compressed distribution. When the executable asks to register the disk, press `Y` and then `Enter`. This won't automatically register it; you'll need to do it manually as shown in the backup and restoration section of this tutorial.
687703
688-
Before running the command, ensure the Linux distribution is stopped by executing `wsl --shutdown` to stop all Linux distributions.
704+
Remove the old disk with:
705+
706+
```bash
707+
wsl --unregister Ubuntu
708+
```
709+
710+
And register the new disk with:
711+
712+
```bash
713+
wsl --import Ubuntu C:\path\to\ext4.vhdx
714+
```
715+
716+
> **Warning**: Backup your Linux distribution before compressing it to avoid losing data in case of errors.
689717
690718
### LAN and VPN Network Mode
691719
@@ -797,4 +825,8 @@ Yes, WSL 2 supports graphical applications through the WSLg (Windows Subsystem f
797825
798826
### Can I use WSL in production scenarios?
799827
800-
WSL is designed as a development tool and is not recommended for production use.
828+
WSL is designed as a development tool and is not recommended for production use.
829+
830+
### Can I run Docker Engine alongside Docker Desktop?
831+
832+
No, you can only run one at a time. It is possible to have both installed, but only one can be running at any given time.

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
- [É possível acessar aplicações rodando no WSL 2 pelo Windows?](#é-possível-acessar-aplicações-rodando-no-wsl-2-pelo-windows)
103103
- [É possível rodar aplicações gráficas no WSL 2?](#é-possível-rodar-aplicações-gráficas-no-wsl-2)
104104
- [Posso usar o WSL em cenários de produção?](#posso-usar-o-wsl-em-cenários-de-produção)
105+
- [Posso rodar o Docker Engine junto com o Docker Desktop?](#posso-rodar-o-docker-engine-junto-com-o-docker-desktop)
105106
- [Quer configurar um ambiente mais produtivo no Windows?](#quer-configurar-um-ambiente-mais-produtivo-no-windows)
106107

107108
</details>
@@ -682,7 +683,9 @@ Para diminuir ative o modo `sparse` do WSL 2, que é a compactação automática
682683
sparseVhd=true
683684
```
684685

685-
Esta opção só funcionará para novos discos virtuais, para os discos virtuais já criados, execute o comando:
686+
Esta opção só funcionará para novos discos virtuais.
687+
688+
Para os discos virtuais já criados, execute o comando:
686689

687690
```bash
688691
wsl --manage "Ubuntu" --set-sparse true
@@ -693,6 +696,23 @@ Isto irá converter o disco virtual para o modo sparse, que é a compactação a
693696

694697
Antes de executar o comando, verifique se a distribuição Linux está parada, execute o comando `wsl --shutdown` para parar todas as distribuições Linux.
695698

699+
Se você já tinha uma distribuição antiga e após aplicar o modo sparse, o disco virtual não diminuiu, você pode compacta-lo manualmente.
700+
701+
Use a ferramenta [wslcompact](https://github.com/okibcn/wslcompact) para realizar este procedimento. Basicamente esta ferramenta será um executável ativo no `PowerShell` e ao executá-lo ele irá exportar e importar o disco virtual, forçando o WSL a compacta-lo.
702+
703+
Execute o comando:
704+
705+
```bash
706+
wslcompact -c Ubuntu
707+
```
708+
709+
Será gerado um novo disco virtual chamado de `ext4.vhdx` que será sua distribuição compactada. Quando o executável pedir para registar o disco, coloque `Y` e pressione `Enter`, isto não fará ele registrar, você deverá fazer isto manualmente como foi mostrado na seção de backup e restauração deste tutorial.
710+
711+
Remova o disco antigo com o comando `wsl --unregister Ubuntu` e registre o novo disco com o comando `wsl --import Ubuntu C:\caminho\ext4.vhdx`.
712+
713+
> Cuidado: Faça um backup da sua distribuição Linux antes de compacta-la, pois você pode cometer um erro e perder seu Linux.
714+
715+
696716
### Rede em modo LAN e VPN
697717

698718
Como o WSL é virtualizado, há uma outra interface de rede, por isso se você usa rede LAN (cabeada), ao rodar aplicações e tentar acessar pelo navegador, por exemplo, você não conseguirá acessar. Seria necessário ficar fazendo binding de portas o que não seria produtivo.
@@ -803,6 +823,10 @@ Sim, este o projeto WSLg (Windows Subsystem for Linux GUI) que permite rodar apl
803823

804824
O WSL é uma ferramenta de desenvolvimento e não é recomendado para uso em produção.
805825

826+
### Posso rodar o Docker Engine junto com o Docker Desktop?
827+
828+
Não, só é possível rodar um de cada vez. É até possível ter os dois instalados, mas só um pode ser executado por vez.
829+
806830
### Quer configurar um ambiente mais produtivo no Windows?
807831

808832
Acesse os tutorias abaixo:

0 commit comments

Comments
 (0)