Today I needed to add a few features to an existing .NET Core application. I’m running Fedora 25, but that shouldn’t be an issue, right? because -
It appears that it doesn’t love Fedora 25, because it’s still not officially supported. Instead of hacking around and trying to get this thing working, and wasting my whole day doing so, I thought - why not use Docker?
The idea was simple - create a container that fires up Visual Studio Code inside a container that has .NET Core installed.
The Dockerfile is pretty straight forward -
FROM microsoft/dotnet |
Just build it, and you’re half way there:
docker build --rm -t vscode -f /path/to/Dockerfile |
Now comes the fun part. Figuring out how to fire up Visual Studio Code from inside a container, as if it’s running natively in the host. Challenges:
- Making Visual Studio Code connect to my running x server
- Giving Visual Studio Code all the privileges it needs to run & debug an app
- Running with the current user’s id, to avoid ownership issues
I googled some, figure out the rest, and came out with following script. It’s a little sharp on the edges, and I probably could’ve used Docker Compose, but it does the job!
|
and viola..!