User Tools

Site Tools


apps:docker:dockerdesktopforwindows

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
apps:docker:dockerdesktopforwindows [2024-06-06 18:50] Manuel Freiapps:docker:dockerdesktopforwindows [2024-06-13 02:48] (current) Manuel Frei
Line 1: Line 1:
 ====== Docker Desktop for Windows ====== ====== Docker Desktop for Windows ======
  
-FIXME FIXME FIXME+===== Purpose / Usage ===== 
 + 
 +Docker Desktop is a UI to help developers working with the Docker engine. <color #ed1c24>It is **not** intended for use in production.</color> 
 + 
 +  * It only works within an interactive user session 
 +  * There are memory usage problems: [[https://github.com/docker/for-win/issues/12944|GitHub: docker/for-win Issue #12944]] 
  
 ===== Configuration ===== ===== Configuration =====
Line 12: Line 18:
  
 Default configuration as of Docker Desktop for Windows version 4.30.0 (2024-06-06). Default configuration as of Docker Desktop for Windows version 4.30.0 (2024-06-06).
-<code json daemon.json>+<code JavaScript daemon.json>
 { {
  "builder": {  "builder": {
Line 24: Line 30:
 </code> </code>
  
-The default log driver is json-file. All the lines that are written to the stdout/console are saved to a json file. The log file is created at the same time the container is created and will grow until the container gets deleted. This can lead to disks getting full. To prevent this situations, logrotation can be configured  +The default log driver is json-file. All the lines that are written to the stdout/console are saved to a json file. The log file is created at the same time the container is created and will grow until the container gets deleted. This can lead to disks getting full. To prevent this situations, log rotation can be configured
-<code json daemon.json>+ 
 +<code JavaScript daemon.json
 +
 +  "log-driver": "json-file", 
 +  "log-opts":
 +    "max-size": "100m", 
 +    "max-file": "3" 
 +  } 
 +
 +</code> 
 + 
 +Together with the default configuration, it looks like this. 
 +<code JavaScript daemon.json>
 { {
   "builder": {   "builder": {
Line 46: Line 64:
 <code> <code>
 %UserProfile%\.wslconfig %UserProfile%\.wslconfig
 +</code>
  
 +<code ini>
 [experimental] [experimental]
 autoMemoryReclaim=gradual autoMemoryReclaim=gradual
Line 62: Line 82:
 </code> </code>
  
-===== Shrinking VHDX =====+===== WSL2 Backend =====
  
 +WSL2 is the recommended backend
  
 +  * "%LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx" ("C:\Users\xxx\Docker\wsl\data\ext4.vhdx")
 +  * "%LOCALAPPDATA%\Docker\wsl\main\ext4.vhdx" ("C:\Users\xxx\Docker\wsl\main\ext4.vhdx")
  
-<code> 
  
-PS C:\> Get-Item C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx+==== List Distributions ====
  
 +<code>
 +wsl -l -v
 +</code>
  
-    Directory: C:\Users\xxx\AppData\Local\Docker\wsl\data+<code - Example> 
 +PS C:\wsl -l -v 
 +  NAME                   STATE           VERSION 
 +* docker-desktop-data    Running         2 
 +  docker-desktop         Running         2 
 +</code>
  
 +<code>
 +wsl -d docker-desktop
 +</code>
  
-Mode                 LastWriteTime         Length Name +<code> 
-----                 -------------         ------ ---- +PS C:\> wsl --
--a----        04/06/2024     15:29   210780553216 ext4.vhdx+  NAME                   STATE           VERSION 
 +* docker-desktop-data    Running         2 
 +  docker-desktop         Running         2
  
 +PS C:\> wsl -d docker-desktop
 +DESKTOP-4D1F8L4:/#
 +</code>
  
-https://learn.microsoft.com/en-us/powershell/module/hyper-v/optimize-vhd?view=windowsserver2022-ps+==== Shrink VHDX ====
  
-PS C:\> Optimize-VHD -Path c:\test\dynamic.vhdx -Mode Full +The virtual disks (VHDX) for the WSL2 VMs will grow to contain all the container dataIf they get too big you have to do an offline shrink operation to get them back to a smaller size.
-PS C:\> Optimize-VHD -Path c:\test\dynamic.vhdx -Mode Retrim+
  
 +Make sure, the Docker Engine is stopped and close Docker Desktop for Windows.
  
-PS C:\> wsl --shutdown+Shutdown the WSL2 distributions. 
 +<code> 
 +wsl --shutdown 
 +</code>
  
-PS C:\> Optimize-VHD C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx  -Mode Full+Shrink both disks with "Full" mode. Check this [[https://learn.microsoft.com/en-us/powershell/module/hyper-v/optimize-vhd?view=windowsserver2022-ps|link]] for more information about the trimming modes. 
 +<code> 
 +Optimize-VHD -Path "C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx-Mode Full 
 +Optimize-VHD -Path "C:\Users\xxx\AppData\Local\Docker\wsl\main\ext4.vhdx" -Mode Full 
 +</code>
  
 +If Optimize-VHD is done, just start Docker Desktop for Windows again.
  
 +Example.
 +<code>
 PS C:\> Get-Item C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx PS C:\> Get-Item C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx
- 
  
     Directory: C:\Users\xxx\AppData\Local\Docker\wsl\data     Directory: C:\Users\xxx\AppData\Local\Docker\wsl\data
- 
  
 Mode                 LastWriteTime         Length Name Mode                 LastWriteTime         Length Name
 ----                 -------------         ------ ---- ----                 -------------         ------ ----
--a----        04/06/2024     16:04    17706254336 ext4.vhdx+-a----        04/06/2024     15:29   210780553216 ext4.vhdx
  
 +PS C:\> wsl --shutdown
 +PS C:\> Optimize-VHD C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx -Mode Full
 +PS C:\> Get-Item C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx
  
 +    Directory: C:\Users\xxx\AppData\Local\Docker\wsl\data
  
-PS C:\> wsl --+Mode                 LastWriteTime         Length Name 
-  NAME                   STATE           VERSION +----                 -------------         ------ ---- 
-* docker-desktop-data    Running         2 +-a----        04/06/2024     16:04    17706254336 ext4.vhdx 
-  docker-desktop         Running         2+</code>
  
-PS C:\> wsl -d docker-desktop +===== Links =====
-DESKTOP-4D1F8L4:/#+
  
 +  * [[https://www.docker.com/blog/new-docker-desktop-wsl2-backend/|Introducing the Docker Desktop WSL 2 Backend]]
  
- 
-</code> 
  
apps/docker/dockerdesktopforwindows.1717692601.txt.gz · Last modified: 2024-06-06 18:50 by Manuel Frei