'Automatically set 'xhost +local:root' in vscode for docker

I am debugging a GUI application from within vscode running in a docker container. Currently, I need to run the command xhost +local:root in an integrated vscode terminal, before I can launch the container with the "Remote - Containers" extension and view the visual output.

I am wondering, if I can automate this, e.g. running the command xhost +local:root in the devcontainer.json or similar so that I do not have to run it manually before connecting?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source