docker-in-docker feature makes X11 bind mount not working
- VSCode Version: 1.64.1
- Local OS Version: Windows_NT x64 10.0.22000, WSL2, WLSg
- Local chip architecture: x86
- Reproduces in: Remote - Containers
- Name of Dev Container Definition with Issue: docker-in-docker
Steps to Reproduce:
- this feature snippet inside devcontainer.json:
"features": {
"docker-in-docker": {
"version": "latest",
"moby": true
}
...
- makes this snippet inside devcontainer.json not working:
"runArgs": [
"-v",
"/tmp/.X11-unix:/tmp/.X11-unix"
],
it makes ls -lah /tmp/.X11-unix/ no result, so I can't run gui app in docker container. When I comment 'docker-in-docker' snippet out, then it works.
Other mounts like this works fine, ls -lah /test has results:
"runArgs": [
"-v",
"/test:/test",
],
Docker in docker mounts some host locations - one of which being /tmp. https://github.com/moby/moby/blob/ea5b4765d9d9a5aa5cab39f7119cffe74be874ce/hack/dind#L24
If you use Docker Desktop with WSL, this mount point is likely in the Docker Desktop WSL distro rather than the one you are using. I'm not sure there's a workaround.
I'd recommend looking at the desktop-lite script rather than using X forwarding. X tends to be slow in comparison.
Thanks for your help. I'm sorry, but i'm not a docker/OS expert, just a humble web dev, so I can't help solve this much.
I looked into code you've linked and tried to prevent dind from mounting it, since I know that when I mount it myself, it just works. I got it working with this hackish mounting. Dunno how or why, but it just works:
"runArgs": ["-v", "/tmp:/tmp", "-v", "/tmp/.X11-unix:/tmp/.X11-unix"],
Now I can run playwright in GUI headed chrome (needs X11) and AWS sam local start-api (needs docker-in-docker - spins docker containers) inside devcontainer. That is my goal. I would use docker-FROM-docker, but can't get AWS sam local start-api work with that. I must wait untill aws will support running sam from container.
I do use Docker Desktop with WSL2, wslg and I'm pretty satisfied with running gui apps via X forwarding, no issues with slowiness, I'm running just browser so it shouldn't be extra demanding. The most important thing for me is, that it's one-liner -v /tmp/.X11-unix:/tmp/.X11-unix - boom gui works (sometimes not as in this case ^^). Thanks for your suggestion about desktop-lite fluxbox, but it seems pretty complex for setup to me in comparison with just forwarding X11 which I feel should be used for wslg?