How to prevent user conflict in WSL + Docker + VS Code setup?

I have WSL + Docker + VS Code setup. The files I’m working on are in WSL filesystem and mounted to a Docker container.

To run the files in Docker container, it requires user www-data but I can’t save the files and do git operation in my VS Code because they’re in my WSL filesystem and it requires my WSL local user to save the files/run git operation.

So I have to sudo chown back and forth just to make sure I can run the files in Docker container and save the files/do git operation in my WSL filesystem.

Is there a way to make files work in WSL and Docker container without having to sudo chown back and forth?

1 Like