美文网首页
在wsl的docker中调用windows下程序

在wsl的docker中调用windows下程序

作者: Cola_Mr | 来源:发表于2025-02-21 10:05 被阅读0次
wsl1中可以尝试这样mount
docker run --rm -it --privileged \
    --mount type=bind,source=/mnt,target=/mnt \
    --mount type=bind,source=/run/WSL,target=/run/WSL \
    --mount type=bind,source=/etc/passwd,target=/etc/passwd,readonly \
    --mount type=bind,source=/etc/group,target=/etc/group,readonly \
    --mount "type=bind,source=$HOME,target=$HOME" \
    --workdir "$HOME" \
    -u $(id -u):$(id -g) \
    --env WSLENV="${WSLENV}" \
    --env WSL_DISTRO_NAME="${WSL_DISTRO_NAME}" \
    --env WSL_INTEROP="${WSL_INTEROP}" \
    --env WT_PROFILE_ID="${WT_PROFILE_ID}" \
    --env WT_SESSION="${WT_SESSION}" \
    ubuntu \
    sh -c '/mnt/c/Windows/system32/notepad.exe'

wsl2中尝试这样mount
docker run --rm -it --privileged \
--mount type=bind,source=/init,target=/init \
--mount type=bind,source=/mnt,target=/mnt \
--mount type=bind,source=/run/WSL,target=/run/WSL \
--env WSL2_GUI_APPS_ENABLED="${WSL2_GUI_APPS_ENABLED}" \
--env WSL_INTEROP="${WSL_INTEROP}" \
--env PULSE_SERVER="${PULSE_SERVER}" \
ubuntu \
bash -c '"/mnt/c/Support Files/notepad.exe"'

相关文章

网友评论

      本文标题:在wsl的docker中调用windows下程序

      本文链接:https://www.haomeiwen.com/subject/ivdmpjtx.html