2025-04-20-docker desktop Settings Resources
2025-04-20-docker desktop Settings Resources
docker desktop Settings
Resources:
Advanced
You are using the WSL 2 backend, so resource limits are managed by Windows.
You can configure limits on the memory, CPU, and swap size allocated to WSL 2 in a .wslconfig file.
disk image location
C:\Users\lily_\AppData\Local\Docker\wsl [Browse]
Resource Saver
✔ Enable Resource Saver
Reduces CPU and memory utilization when no containers are running.
Exit from Resource Saver mode happens automatically when containers are started.
Use the slider to set the duration of time between no containers running and Docker Desktop entering Resource Saver mode.
30sec 10min 20min 30min 40min 50min 60min (default 5min)
File sharing
Directory sharing is limited to specific directories
These directories(and their subdirectories) can be bind mounted into Docker containers. You can check the documentation for more details.
c:\path\to\exported\diretory Browse
Proxies
Docker Desktop automatically detects and uses the system proxy.
Alternatively, the proxy server can be manually specified.
The supported proxies are HTTP/HTTPS and AOCKS5.
⚪ Manual proxy configuration
Web Server(HTTP)
Secure Web Server(HTTPS)
Network
Configure the way Cocker containers interact with the network
Docker subnet
192.168.65.0/24
default: 192.168.65.0/24
⚪ Enable host networking
Host networking allows containers that are started with -net=host use localhost
to connect to TCP and UDP services on the host. It will automatically allow software
on the host to use localhost to connect to TCP and UDP services in the container.
Default networking mode
IPv4 only / IPv6 only / Dual IPv4/IPv6
(Docker networks will support only IPv4 by default. This can be overridden on per-network basis.
Inhibit DNS resolution for IPv4 / IPv6
(Base on selected network mode)
Auto(recommended / filter IPv6(AAAA records) / No filtering
(Docker will detect whether your host supports IPv4 and/or IPv6. It will automatically
filter unsupported DNS record types(A or AAAA) to prevent containers from attempting
failed connections This can be overridden on a per-network basis.
WSL integration
Configure which WSL distress you want to access Docker from.
✔ Enable integration with my default WSL bistro
You don't have any WSL 2 distress installed. Please convert a WSL 1 bistro to WSL 2,
or install a new bistro and it will appear here.
[Refetch distros]
非常好 👌 你打得很完整,我來逐段解釋 Docker Desktop → Settings → Resources 的各個選項,並告訴你「是否需要動」「建議怎麼設」:
🔹 Advanced
提示:You are using the WSL 2 backend…
👉 表示你選用 WSL2,資源(CPU、記憶體、Swap)不是在 Docker Desktop 裡設,而是透過.wslconfig
檔案控制。- 預設就夠用了,不需要馬上改。
- 如果你將來發現「容器跑起來很慢」或「Windows 記憶體不足」,才需要去調整。
Disk image location
👉 存放 Docker 的虛擬磁碟檔(容器 & 映像)。- 建議保持預設(
C:\Users\lily_\AppData\Local\Docker\wsl
)。 - 如果 C 槽快滿,才考慮搬到 D 槽或外接 SSD。
- 建議保持預設(
🔹 Resource Saver
Enable Resource Saver(✔ 建議勾選)
- 沒有容器在跑時,Docker Desktop 會「休眠」,減少 CPU / RAM 佔用。
- 只要一啟動容器,就會自動恢復正常運作。
- Slider 時間:保持 5 分鐘(預設),夠用。
🔹 File Sharing
這裡決定「哪些 Windows 資料夾」可以掛載進容器。
- 預設沒有開放(安全一點)。
- 如果你要讓容器存取某個資料夾(例如程式碼目錄),就在這裡 新增路徑。
- 舉例:你有專案在
C:\Users\lily_\Projects
,就要加這個路徑。
🔹 Proxies
- Docker Desktop 會自動抓系統 Proxy 設定。
- 除非你公司有規定要用 Proxy 上網,否則 保持自動偵測 就好,不要亂勾。
🔹 Network
Docker subnet(192.168.65.0/24)
- 預設即可,不建議隨便改。
- 如果和你家網路 IP 衝突(很少見),才需要換一個子網段。
Enable host networking(⚪ 建議不要開)
- Host 模式安全性比較低,除非你知道要用(像跑某些伺服器需要),否則不要勾。
Default networking mode
- 建議用 IPv4 only(最穩定,絕大多數容器都跑 IPv4)。
- 如果將來你要玩 IPv6 容器,再改成 Dual IPv4/IPv6。
Inhibit DNS resolution…
- 建議保持 **Auto (recommended)**。Docker 會自動判斷。
🔹 WSL Integration
Enable integration with my default WSL distro(✔ 建議勾選)
- 這樣你的 WSL2 Linux 環境(例如 Ubuntu)可以直接用
docker
指令。 - 目前提示「You don’t have any WSL2 distro installed」,表示你還沒裝 WSL2 Linux。
- 之後可以安裝 Ubuntu(建議),在那裡跑 Docker 會更自然。
- 這樣你的 WSL2 Linux 環境(例如 Ubuntu)可以直接用
✅ 總結:建議設定
- Resource Saver → ✔ 開啟(預設 5 分鐘)
- File Sharing → 依專案需求新增路徑
- Proxies → 不動(除非公司有 Proxy)
- Network → 保持 IPv4 only + Auto (recommended)
- WSL Integration → ✔ 勾選,等安裝 Ubuntu 後就能用了
要不要我順便給你一份 .wslconfig
範例,讓你知道將來如果要限制 WSL2 的 CPU / RAM 要怎麼寫?(例如避免 Docker 佔太多記憶體)
好 👍 我給你一個 .wslconfig
範例,這是設定 WSL2 的 CPU / RAM / Swap 限制,避免 Docker 把 Windows 的資源吃光。
📄 建立 .wslconfig
檔案
在 Windows 使用者目錄 建立一個文字檔:
1
C:\Users\<你的帳號>\.wslconfig
(你的帳號應該是
lily_
,所以完整路徑會是C:\Users\lily_\.wslconfig
)複製以下範例內容:
1 | [wsl2] |
⚙️ 參數解釋
memory
限制 WSL2(包含 Docker)最多用多少記憶體。
👉 如果你的電腦有 16GB RAM,可以設 4GB~8GB。processors
限制最多用幾顆 CPU。
👉 建議一半左右(你有 4 核心就設 2)。swap
類似虛擬記憶體(用硬碟當備用記憶體)。
👉 設個 1~2GB 就好,不要太大。localhostForwarding
預設是 true,讓容器能透過localhost
訪問主機服務(例如 DB)。
🚀 套用設定
修改 .wslconfig
後,要重新啟動 WSL2 才會生效:
在 PowerShell 輸入:
1
wsl --shutdown
(會關閉所有 WSL2 / Docker 虛擬機)
再重新開啟 Docker Desktop,它就會用新的限制。
💡 小技巧:你可以先設定「小一點」(例如 memory=2GB, processors=2),然後觀察 Docker 運行速度。如果覺得太慢,再調高。
要不要我幫你根據 你電腦的規格(RAM / CPU),算一個比較適合的 .wslconfig
建議值?