重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
docker-platform-guide by josiahsiegel/claude-plugin-marketplace
npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill docker-platform-guide强制规定:在 Windows 上始终对文件路径使用反斜杠
在 Windows 上使用编辑或写入工具时,必须在文件路径中使用反斜杠 (\),而不是正斜杠 (/)。
示例:
D:/repos/project/file.tsxD:\repos\project\file.tsx这适用于:
除非用户明确要求,否则切勿创建新的文档文件。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
此技能提供针对 Windows、Linux 和 macOS 平台的 Docker 差异、注意事项和优化的详细指导。
容器技术:
存储驱动:
# 检查当前驱动
docker info | grep "Storage Driver"
# 推荐:overlay2
# /etc/docker/daemon.json
{
"storage-driver": "overlay2"
}
守护进程配置 (/etc/docker/daemon.json):
{
"storage-driver": "overlay2",
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"live-restore": true,
"userland-proxy": false,
"userns-remap": "default",
"icc": false,
"default-ulimits": {
"nofile": {
"Name": "nofile",
"Hard": 64000,
"Soft": 64000
}
}
}
用户命名空间重映射:
# 在 daemon.json 中启用
{
"userns-remap": "default"
}
# 重启 Docker
sudo systemctl restart docker
# 结果:容器中的 root = 主机上的非特权用户
# 检查 SELinux 状态
sestatus
# 启用 SELinux 运行容器
docker run --security-opt label=type:svirt_sandbox_file_t myimage
# 卷标签
docker run -v /host/path:/container/path:z myimage # 私有标签
docker run -v /host/path:/container/path:Z myimage # 共享标签
# 检查 AppArmor 状态
sudo aa-status
# 使用默认的 Docker 配置文件运行
docker run --security-opt apparmor=docker-default myimage
# 创建自定义配置文件
sudo aa-genprof docker run myimage
# 检查 Docker 服务状态
sudo systemctl status docker
# 启用开机启动
sudo systemctl enable docker
# 重启 Docker
sudo systemctl restart docker
# 查看日志
sudo journalctl -u docker -f
# 配置服务
sudo systemctl edit docker
# 检查 cgroup 版本
stat -fc %T /sys/fs/cgroup/
# 如果使用 cgroup v2,确保 Docker 版本 >= 20.10
# /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
Ubuntu/Debian:
# 安装 Docker
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
# 非 root 用户
sudo usermod -aG docker $USER
RHEL/CentOS/Fedora:
# 安装 Docker
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io
# 启动 Docker
sudo systemctl start docker
sudo systemctl enable docker
# 非 root 用户
sudo usermod -aG docker $USER
Alpine:
# 安装 Docker
apk add docker docker-compose
# 启动 Docker
rc-update add docker boot
service docker start
资源分配:
Docker Desktop → 偏好设置 → 资源 → 高级
- CPU:根据工作负载分配(默认:可用的一半)
- 内存:慷慨分配(默认:2GB,建议 4-8GB)
- 交换空间:至少 1GB
- 磁盘镜像大小:开发建议 60GB 以上
文件共享性能:
传统的 osxfs 速度较慢。改进方法:
volumes:
# 主机写入延迟(最适合源代码)
- ./src:/app/src:delegated
# 容器写入缓存(最适合构建输出)
- ./build:/app/build:cached
# 默认一致性(最慢但最安全)
- ./data:/app/data:consistent
网络访问:
# 从容器访问主机
host.docker.internal
# 示例:连接到主机的 PostgreSQL
docker run -e DATABASE_URL=postgresql://host.docker.internal:5432/db myapp
架构注意事项:
# 检查镜像架构
docker image inspect node:20-alpine | grep Architecture
# M 系列 Mac 是 ARM64
# 有些镜像仅适用于 AMD64
# 构建多平台镜像
docker buildx build --platform linux/amd64,linux/arm64 -t myapp .
# 在 ARM 上运行 AMD64 镜像(通过仿真)
docker run --platform linux/amd64 myimage # 较慢
Rosetta 2 集成:
Docker Desktop → 开发中的功能 → 对 x86/amd64 仿真使用 Rosetta
在 Apple Silicon 上实现更快的 AMD64 仿真。
常规:
资源:
CPU:4-6 个(用于开发)
内存:6-8 GB(用于开发)
交换空间:1-2 GB
磁盘镜像大小:100+ GB(动态增长)
Docker 引擎:
{
"builder": {
"gc": {
"enabled": true,
"defaultKeepStorage": "20GB"
}
},
"experimental": false,
"features": {
"buildkit": true
}
}
# macOS 用户 ID 和组 ID
id -u # 通常是 501
id -g # 通常是 20
# 在容器中匹配
docker run --user 501:20 myimage
# 或者在 Dockerfile 中
RUN adduser -u 501 -g 20 appuser
USER appuser
# 用于开发的 docker-compose.yml
version: '3.8'
services:
app:
build: .
volumes:
# 源代码使用委托挂载(性能更好)
- ./src:/app/src:delegated
# node_modules 放在卷中(比绑定挂载快得多)
- node_modules:/app/node_modules
ports:
- "3000:3000"
environment:
- NODE_ENV=development
volumes:
node_modules:
问题: 文件同步慢 解决方案:
问题: CPU 使用率高 解决方案:
问题: 端口已被占用 解决方案:
# 查找使用端口的进程
lsof -i :PORT
kill -9 PID
1. Windows 上的 Linux 容器 (LCOW):
2. Windows 容器:
WSL2 后端(推荐):
Hyper-V 后端:
启用 WSL2:
# 以管理员身份运行
wsl --install
# 或者手动
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# 将 WSL2 设置为默认
wsl --set-default-version 2
# 安装 Ubuntu(或其他发行版)
wsl --install -d Ubuntu
Docker Desktop 集成:
设置 → 资源 → WSL 集成
- 启用与默认发行版的集成
- 选择其他发行版
路径格式:
# 正斜杠(推荐,到处都适用)
docker run -v C:/Users/name/project:/app myimage
# 反斜杠(在某些上下文中需要转义)
docker run -v C:\Users\name\project:/app myimage
# 在 docker-compose.yml 中(正斜杠)
volumes:
- C:/Users/name/project:/app
# 或者相对路径
volumes:
- ./src:/app/src
关键问题: 在 Windows 上的 Git Bash (MINGW) 中使用 Docker 时,自动路径转换会破坏卷挂载。
问题描述:
# 在 Git Bash 中键入的内容:
docker run -v $(pwd):/app myimage
# Git Bash 转换后的内容(已损坏):
docker run -v C:\Program Files\Git\d\repos\project:/app myimage
解决方案:
1. MSYS_NO_PATHCONV(推荐):
# 每个命令的修复
MSYS_NO_PATHCONV=1 docker run -v $(pwd):/app myimage
# 会话范围的修复(添加到 ~/.bashrc)
export MSYS_NO_PATHCONV=1
# 函数包装器(对所有 Docker 命令自动生效)
docker() {
(export MSYS_NO_PATHCONV=1; command docker.exe "$@")
}
export -f docker
2. 双斜杠变通方法:
# 使用双前导斜杠以防止转换
docker run -v //c/Users/project:/app myimage
# 与 $(pwd) 一起使用也有效
docker run -v //$(pwd):/app myimage
3. 命名卷(无路径问题):
# 命名卷无需任何修复即可工作
docker run -v my-data:/data myimage
无需修改即可工作的内容:
需要 MSYS_NO_PATHCONV 的内容:
$(pwd) 的绑定挂载Shell 检测:
# 检测 Git Bash/MINGW 并自动配置
if [ -n "$MSYSTEM" ] || [[ "$(uname -s)" == MINGW* ]]; then
export MSYS_NO_PATHCONV=1
echo "检测到 Git Bash - 已启用 Docker 路径转换修复"
fi
推荐的 ~/.bashrc 配置:
# Git Bash 上的 Docker 修复
if [ -n "$MSYSTEM" ]; then
export MSYS_NO_PATHCONV=1
fi
有关全面的路径转换文档、故障排除和示例,请参阅 docker-git-bash-guide 技能。
配置共享驱动器:
Docker Desktop → 设置 → 资源 → 文件共享
添加:C:\, D:\, 等。
性能注意事项:
问题: CRLF 与 LF 行尾符
解决方案:
# Git 配置
git config --global core.autocrlf input
# 或者每个仓库(.gitattributes)
* text=auto
*.sh text eol=lf
*.bat text eol=crlf
# 在 Dockerfile 中用于脚本
FROM alpine
COPY --chmod=755 script.sh /
# 确保 LF 行尾符
RUN dos2unix /script.sh || sed -i 's/\r$//' /script.sh
# 允许 Docker Desktop
New-NetFirewallRule -DisplayName "Docker Desktop" -Direction Inbound -Program "C:\Program Files\Docker\Docker\Docker Desktop.exe" -Action Allow
# 检查被阻止的端口
netstat -ano | findstr :PORT
# 在容器中运行 PowerShell
docker run -it mcr.microsoft.com/powershell:lts-7.4-windowsservercore-ltsc2022
# Windows 容器示例
docker run -it mcr.microsoft.com/windows/servercore:ltsc2022 cmd
# 检查容器类型
docker info | Select-String "OSType"
问题: WSL2 VHDX 增长但不会收缩
解决方案:
# 停止 Docker Desktop 和 WSL
wsl --shutdown
# 压缩磁盘镜像(以管理员身份运行)
# 方法 1:Optimize-VHD(需要 Hyper-V 工具)
Optimize-VHD -Path "$env:LOCALAPPDATA\Docker\wsl\data\ext4.vhdx" -Mode Full
# 方法 2:diskpart
diskpart
# 在 diskpart 中:
select vdisk file="C:\Users\YourName\AppData\Local\Docker\wsl\data\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
# 用于 Windows 的 docker-compose.yml
version: '3.8'
services:
app:
build: .
volumes:
# 使用正斜杠
- ./src:/app/src
# 使用命名卷以获得更好的性能
- node_modules:/app/node_modules
ports:
- "3000:3000"
environment:
- NODE_ENV=development
# Windows 特定:确保正确的行尾符
command: sh -c "dos2unix /app/scripts/*.sh && npm start"
volumes:
node_modules:
问题: 权限被拒绝错误 解决方案:
# 以管理员身份运行 Docker Desktop
# 或者授予 Docker Desktop 权限
icacls "C:\ProgramData\DockerDesktop" /grant Users:F /T
问题: 性能慢 解决方案:
\\wsl$\Ubuntu\home\user\project)问题: 找不到路径 解决方案:
${PWD}| 特性 | Linux | macOS | Windows |
|---|---|---|---|
| 性能 | 优秀(原生) | 良好(虚拟机开销) | 良好(WSL2)到一般(Hyper-V) |
| 文件共享 | 原生 | 慢(VirtioFS 正在改进) | 慢(WSL2 中更好) |
| 资源效率 | 最佳 | 良好 | 良好(WSL2) |
| 功能集 | 完整 | 完整 | 完整(LCOW) |
| 生产环境 | 标准 | 仅开发 | 仅开发(LCOW) |
| 易用性 | 中等 | 简单(Docker Desktop) | 简单(Docker Desktop) |
| 成本 | 免费 | 免费(Docker Desktop 个人版) | 免费(Docker Desktop 个人版) |
# 创建 buildx 构建器
docker buildx create --name multiplatform --driver docker-container --use
# 为多个平台构建
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t myimage:latest \
--push \
.
# 在所有平台上都适用
FROM node:20-alpine
# 使用带 --chmod 的 COPY(而不是 RUN chmod,后者较慢)
COPY --chmod=755 script.sh /usr/local/bin/
# 使用环境变量表示路径
ENV APP_HOME=/app
WORKDIR ${APP_HOME}
# 对 CMD/ENTRYPOINT 使用 exec 形式(在 Windows 容器中也适用)
CMD ["node", "server.js"]
version: '3.8'
services:
app:
build: .
volumes:
# 相对路径到处都适用
- ./src:/app/src
# 命名卷(平台无关)
- data:/app/data
environment:
# 使用环境变量
- NODE_ENV=${NODE_ENV:-development}
volumes:
data:
# 使用 buildx 在不同平台上测试
docker buildx build --platform linux/amd64 -t myapp:amd64 --load .
docker run --rm myapp:amd64
docker buildx build --platform linux/arm64 -t myapp:arm64 --load .
docker run --rm myapp:arm64
选择 Linux 用于:
选择 macOS 用于:
选择 Windows 用于:
此平台指南涵盖了主要差异。在投入生产之前,请务必在您的目标部署平台上进行测试。
每周安装次数
70
仓库
GitHub 星标数
21
首次出现
2026年1月24日
安全审计
已安装于
claude-code57
opencode56
gemini-cli54
codex53
cursor50
github-copilot48
MANDATORY: Always Use Backslashes on Windows for File Paths
When using Edit or Write tools on Windows, you MUST use backslashes (\) in file paths, NOT forward slashes (/).
Examples:
D:/repos/project/file.tsxD:\repos\project\file.tsxThis applies to:
NEVER create new documentation files unless explicitly requested by the user.
This skill provides detailed guidance on Docker differences, considerations, and optimizations for Windows, Linux, and macOS platforms.
Container Technologies:
Storage Drivers:
# Check current driver
docker info | grep "Storage Driver"
# Recommended: overlay2
# /etc/docker/daemon.json
{
"storage-driver": "overlay2"
}
Daemon Configuration (/etc/docker/daemon.json):
{
"storage-driver": "overlay2",
"log-driver": "json-file",
"log-opts": {
"max-size": "10m",
"max-file": "3"
},
"live-restore": true,
"userland-proxy": false,
"userns-remap": "default",
"icc": false,
"default-ulimits": {
"nofile": {
"Name": "nofile",
"Hard": 64000,
"Soft": 64000
}
}
}
User Namespace Remapping:
# Enable in daemon.json
{
"userns-remap": "default"
}
# Restart Docker
sudo systemctl restart docker
# Result: root in container = unprivileged user on host
# Check SELinux status
sestatus
# Run container with SELinux enabled
docker run --security-opt label=type:svirt_sandbox_file_t myimage
# Volume labels
docker run -v /host/path:/container/path:z myimage # Private label
docker run -v /host/path:/container/path:Z myimage # Shared label
# Check AppArmor status
sudo aa-status
# Run with default Docker profile
docker run --security-opt apparmor=docker-default myimage
# Create custom profile
sudo aa-genprof docker run myimage
# Check Docker service status
sudo systemctl status docker
# Enable on boot
sudo systemctl enable docker
# Restart Docker
sudo systemctl restart docker
# View logs
sudo journalctl -u docker -f
# Configure service
sudo systemctl edit docker
# Check cgroup version
stat -fc %T /sys/fs/cgroup/
# If using cgroup v2, ensure Docker version >= 20.10
# /etc/docker/daemon.json
{
"exec-opts": ["native.cgroupdriver=systemd"]
}
Ubuntu/Debian:
# Install Docker
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
# Non-root user
sudo usermod -aG docker $USER
RHEL/CentOS/Fedora:
# Install Docker
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io
# Start Docker
sudo systemctl start docker
sudo systemctl enable docker
# Non-root user
sudo usermod -aG docker $USER
Alpine:
# Install Docker
apk add docker docker-compose
# Start Docker
rc-update add docker boot
service docker start
Resource Allocation:
Docker Desktop → Preferences → Resources → Advanced
- CPUs: Allocate based on workload (default: half available)
- Memory: Allocate generously (default: 2GB, recommend 4-8GB)
- Swap: 1GB minimum
- Disk image size: 60GB+ for development
File Sharing Performance:
Traditional osxfs is slow. Improvements:
volumes:
# Host writes delayed (best for source code)
- ./src:/app/src:delegated
# Container writes cached (best for build outputs)
- ./build:/app/build:cached
# Default consistency (slowest but safest)
- ./data:/app/data:consistent
Network Access:
# Access host from container
host.docker.internal
# Example: Connect to host PostgreSQL
docker run -e DATABASE_URL=postgresql://host.docker.internal:5432/db myapp
Architecture Considerations:
# Check image architecture
docker image inspect node:20-alpine | grep Architecture
# M-series Macs are ARM64
# Some images only available for AMD64
# Build multi-platform
docker buildx build --platform linux/amd64,linux/arm64 -t myapp .
# Run AMD64 image on ARM (via emulation)
docker run --platform linux/amd64 myimage # Slower
Rosetta 2 Integration:
Docker Desktop → Features in development → Use Rosetta for x86/amd64 emulation
Faster AMD64 emulation on Apple Silicon.
General:
Resources:
CPUs: 4-6 (for development)
Memory: 6-8 GB (for development)
Swap: 1-2 GB
Disk image size: 100+ GB (grows dynamically)
Docker Engine:
{
"builder": {
"gc": {
"enabled": true,
"defaultKeepStorage": "20GB"
}
},
"experimental": false,
"features": {
"buildkit": true
}
}
# macOS user ID and group ID
id -u # Usually 501
id -g # Usually 20
# Match in container
docker run --user 501:20 myimage
# Or in Dockerfile
RUN adduser -u 501 -g 20 appuser
USER appuser
# docker-compose.yml for development
version: '3.8'
services:
app:
build: .
volumes:
# Source code with delegated (better performance)
- ./src:/app/src:delegated
# node_modules in volume (much faster than bind mount)
- node_modules:/app/node_modules
ports:
- "3000:3000"
environment:
- NODE_ENV=development
volumes:
node_modules:
Problem: Slow file sync Solution:
Problem: High CPU usage Solution:
Problem: Port already in use Solution:
# Find process using port
lsof -i :PORT
kill -9 PID
1. Linux Containers on Windows (LCOW):
2. Windows Containers:
WSL2 Backend (Recommended):
Hyper-V Backend:
Enable WSL2:
# Run as Administrator
wsl --install
# Or manually
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
# Set WSL2 as default
wsl --set-default-version 2
# Install Ubuntu (or other distro)
wsl --install -d Ubuntu
Docker Desktop Integration:
Settings → Resources → WSL Integration
- Enable integration with default distro
- Select additional distros
Path Formats:
# Forward slashes (recommended, works everywhere)
docker run -v C:/Users/name/project:/app myimage
# Backslashes (need escaping in some contexts)
docker run -v C:\Users\name\project:/app myimage
# In docker-compose.yml (forward slashes)
volumes:
- C:/Users/name/project:/app
# Or relative paths
volumes:
- ./src:/app/src
CRITICAL ISSUE: When using Docker in Git Bash (MINGW) on Windows, automatic path conversion breaks volume mounts.
The Problem:
# What you type in Git Bash:
docker run -v $(pwd):/app myimage
# What Git Bash converts it to (BROKEN):
docker run -v C:\Program Files\Git\d\repos\project:/app myimage
Solutions:
1. MSYS_NO_PATHCONV (Recommended):
# Per-command fix
MSYS_NO_PATHCONV=1 docker run -v $(pwd):/app myimage
# Session-wide fix (add to ~/.bashrc)
export MSYS_NO_PATHCONV=1
# Function wrapper (automatic for all Docker commands)
docker() {
(export MSYS_NO_PATHCONV=1; command docker.exe "$@")
}
export -f docker
2. Double Slash Workaround:
# Use double leading slash to prevent conversion
docker run -v //c/Users/project:/app myimage
# Works with $(pwd) too
docker run -v //$(pwd):/app myimage
3. Named Volumes (No Path Issues):
# Named volumes work without any fixes
docker run -v my-data:/data myimage
What Works Without Modification:
What Needs MSYS_NO_PATHCONV:
$(pwd)Shell Detection:
# Detect Git Bash/MINGW and auto-configure
if [ -n "$MSYSTEM" ] || [[ "$(uname -s)" == MINGW* ]]; then
export MSYS_NO_PATHCONV=1
echo "Git Bash detected - Docker path conversion fix enabled"
fi
Recommended ~/.bashrc Configuration:
# Docker on Git Bash fix
if [ -n "$MSYSTEM" ]; then
export MSYS_NO_PATHCONV=1
fi
See the docker-git-bash-guide skill for comprehensive path conversion documentation, troubleshooting, and examples.
Configure Shared Drives:
Docker Desktop → Settings → Resources → File Sharing
Add: C:\, D:\, etc.
Performance Considerations:
Problem: CRLF vs LF line endings
Solution:
# Git configuration
git config --global core.autocrlf input
# Or per-repo (.gitattributes)
* text=auto
*.sh text eol=lf
*.bat text eol=crlf
# In Dockerfile for scripts
FROM alpine
COPY --chmod=755 script.sh /
# Ensure LF endings
RUN dos2unix /script.sh || sed -i 's/\r$//' /script.sh
# Allow Docker Desktop
New-NetFirewallRule -DisplayName "Docker Desktop" -Direction Inbound -Program "C:\Program Files\Docker\Docker\Docker Desktop.exe" -Action Allow
# Check blocked ports
netstat -ano | findstr :PORT
# Run PowerShell in container
docker run -it mcr.microsoft.com/powershell:lts-7.4-windowsservercore-ltsc2022
# Windows container example
docker run -it mcr.microsoft.com/windows/servercore:ltsc2022 cmd
# Check container type
docker info | Select-String "OSType"
Problem: WSL2 VHDX grows but doesn't shrink
Solution:
# Stop Docker Desktop and WSL
wsl --shutdown
# Compact disk image (run as Administrator)
# Method 1: Optimize-VHD (requires Hyper-V tools)
Optimize-VHD -Path "$env:LOCALAPPDATA\Docker\wsl\data\ext4.vhdx" -Mode Full
# Method 2: diskpart
diskpart
# In diskpart:
select vdisk file="C:\Users\YourName\AppData\Local\Docker\wsl\data\ext4.vhdx"
attach vdisk readonly
compact vdisk
detach vdisk
exit
# docker-compose.yml for Windows
version: '3.8'
services:
app:
build: .
volumes:
# Use forward slashes
- ./src:/app/src
# Named volumes for better performance
- node_modules:/app/node_modules
ports:
- "3000:3000"
environment:
- NODE_ENV=development
# Windows-specific: ensure proper line endings
command: sh -c "dos2unix /app/scripts/*.sh && npm start"
volumes:
node_modules:
Problem: Permission denied errors Solution:
# Run Docker Desktop as Administrator
# Or grant permissions to Docker Desktop
icacls "C:\ProgramData\DockerDesktop" /grant Users:F /T
Problem: Slow performance Solution:
\\wsl$\Ubuntu\home\user\project)Problem: Path not found Solution:
${PWD}| Feature | Linux | macOS | Windows |
|---|---|---|---|
| Performance | Excellent (native) | Good (VM overhead) | Good (WSL2) to Fair (Hyper-V) |
| File sharing | Native | Slow (improving with VirtioFS) | Slow (better in WSL2) |
| Resource efficiency | Best | Good | Good (WSL2) |
| Feature set | Complete | Complete | Complete (LCOW) |
| Production | Standard | Dev only | Dev only (LCOW) |
| Ease of use | Moderate | Easy (Docker Desktop) | Easy (Docker Desktop) |
# Create buildx builder
docker buildx create --name multiplatform --driver docker-container --use
# Build for multiple platforms
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-t myimage:latest \
--push \
.
# Works on all platforms
FROM node:20-alpine
# Use COPY with --chmod (not RUN chmod, which is slower)
COPY --chmod=755 script.sh /usr/local/bin/
# Use environment variables for paths
ENV APP_HOME=/app
WORKDIR ${APP_HOME}
# Use exec form for CMD/ENTRYPOINT (works on Windows containers too)
CMD ["node", "server.js"]
version: '3.8'
services:
app:
build: .
volumes:
# Relative paths work everywhere
- ./src:/app/src
# Named volumes (platform-agnostic)
- data:/app/data
environment:
# Use environment variables
- NODE_ENV=${NODE_ENV:-development}
volumes:
data:
# Test on different platforms with buildx
docker buildx build --platform linux/amd64 -t myapp:amd64 --load .
docker run --rm myapp:amd64
docker buildx build --platform linux/arm64 -t myapp:arm64 --load .
docker run --rm myapp:arm64
Choose Linux for:
Choose macOS for:
Choose Windows for:
This platform guide covers the major differences. Always test on your target deployment platform before going to production.
Weekly Installs
70
Repository
GitHub Stars
21
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
claude-code57
opencode56
gemini-cli54
codex53
cursor50
github-copilot48
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
118,400 周安装
| Cost | Free | Free (Docker Desktop Personal) | Free (Docker Desktop Personal) |