User Tools

Site Tools


apps:docker:dockerdesktopforwindows

Differences

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

Link to this comparison view

Next revision
Previous revision
apps:docker:dockerdesktopforwindows [2024-06-05 16:14] – created 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 =====
  
-===== Config =====+Docker Desktop is a UI to help developers working with the Docker engine. <color #ed1c24>It is **not** intended for use in production.</color>
  
-<code>+  * 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]]
  
-%UserProfile%\.docker\daemon.json 
  
 +===== Configuration =====
 +
 +==== Docker Daemon ====
 +
 +<code>
 +%UserProfile%\.docker\daemon.json
 +</code>
  
-# before:+Default configuration as of Docker Desktop for Windows version 4.30.0 (2024-06-06). 
 +<code JavaScript daemon.json>
 { {
  "builder": {  "builder": {
Line 20: Line 28:
  "experimental": false  "experimental": false
 } }
 +</code>
  
-# after:+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 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 37: Line 58:
   }   }
 } }
 +</code>
  
 +==== WSL2 ====
 +
 +<code>
 +%UserProfile%\.wslconfig
 </code> </code>
  
 +<code ini>
 +[experimental]
 +autoMemoryReclaim=gradual
  
-===== Shring VHDX ===== 
  
-<code>+[wsl2] 
 +memory=24GB 
 +networkingMode=mirrored 
 +dnsTunneling=true 
 +firewall=true 
 +autoProxy=true 
 +[experimental] 
 +autoMemoryReclaim=gradual
  
-PS C:\Get-Item C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx+</code>
  
 +===== WSL2 Backend =====
  
-    Directory: C:\Users\xxx\AppData\Local\Docker\wsl\data+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")
  
-Mode                 LastWriteTime         Length Name 
-----                 -------------         ------ ---- 
--a----        04/06/2024     15:29   210780553216 ext4.vhdx 
  
 +==== List Distributions ====
  
-https://learn.microsoft.com/en-us/powershell/module/hyper-v/optimize-vhd?view=windowsserver2022-ps+<code> 
 +wsl --v 
 +</code>
  
-PS C:\> Optimize-VHD -Path c:\test\dynamic.vhdx -Mode Full +<code - Example> 
-PS C:\> Optimize-VHD -Path c:\test\dynamic.vhdx -Mode Retrim+PS C:\> wsl --
 +  NAME                   STATE           VERSION 
 +* docker-desktop-data    Running         2 
 +  docker-desktop         Running         2 
 +</code>
  
 +<code>
 +wsl -d docker-desktop
 +</code>
  
-PS C:\> wsl --shutdown+<code> 
 +PS C:\> wsl -l -v 
 +  NAME                   STATE           VERSION 
 +* docker-desktop-data    Running         2 
 +  docker-desktop         Running         2
  
-PS C:\> Optimize-VHD C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx  -Mode Full+PS C:\> wsl -d docker-desktop 
 +DESKTOP-4D1F8L4:/# 
 +</code>
  
 +==== Shrink VHDX ====
  
-PS C:\> Get-Item C:\Users\xxx\AppData\Local\Docker\wsl\data\ext4.vhdx+The virtual disks (VHDX) for the WSL2 VMs will grow to contain all the container data. If they get too big you have to do an offline shrink operation to get them back to a smaller size.
  
 +Make sure, the Docker Engine is stopped and close Docker Desktop for Windows.
  
-    Directory: C:\Users\xxx\AppData\Local\Docker\wsl\data+Shutdown the WSL2 distributions. 
 +<code> 
 +wsl --shutdown 
 +</code>
  
 +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
 +
 +    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.1717596894.txt.gz · Last modified: 2024-06-05 16:14 by Manuel Frei