Nice writeup.
One thing I’d like to add, which I’ve incorporated into my own devcontainers is that you can also install the vendor toolchains, by using docker’s COPY command to copy a fixed version installer and running the installer through the commandline.
What this allows you to do, is to then open and use your vendor’s configuration and code generation tools.
You can forward your X-server to the devcontainer by adding this mount to your devcontainer.json:
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind"
]
This also means that if you run windows, and use docker with the wsl2 backend (which you should on windows) and you’re running on an updated windows 11 release, you will be able to see the programs launched in the devcontainer as they go:
devcontainer’s X11-server → WSL2’s X11-server → WSLg
Same goes for other nice tools like forwarding your ssh-agent to the container, which allows you to use ssh keys stored in your agent from within the devcontainer, to commit/pull/push and such
For that there is this mount (replace /home/developer
with your devcontainer user’s home dir):
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/developer/.ssh,type=bind"
]
There’s also been two talks about this kind of setup at emBO++ 2023:
My lightning talk: (Florian Humblot - Getting Rid of “It Works on my Machine” - emBO++ 2023 - YouTube
And a talk from Jonas Nussdorfer (more specifically about Zephyr): Hands on Molding VS code into a care free development environment to develop with Zephyr RTOS - emBO - YouTube