VSCode and Docker: How to get intellisense and code-completion working?

For folks developing with fastai using Docker … how can I get intellisense and code-completion back?

Docker is great. I love it. But I also love my intellisense and code-completion that I’ve been able to use in the past. Taking for example, the render fastai starter repo, is there a to get intellisense/auto-complete working when developing locally for my python, pytorch, and fastai packages?

You could just install fastai and other dependencies locally as well as in docker but then you have to maintain both environments. Though you could probably modify that requirements file which currently only has the linux URL for PyTorch to have both Linux and Windows URLs conditional on OS. Or conda has a PyTorch dependency that works across both. It is also better integrated into VSCode at least on Windows.

There are Docker extensions for VSCode (and the full Visual Studio) but from a quick scan they don’t address this. Intellisense/debugging etc. seems to depend on the remote debugging features of the base language. Python doesn’t have this in the base unlike say Node or ASP.NET which do remote dev well.
You could setup ssh or perhaps rmate within the docker as used in https://github.com/rafaelmaiolla/remote-vscode. That would add extra stuff to your docker, but you could make this conditional on a variable, or have dev and non-dev tags. Though that doesn’t really work for intellisense as it would only work while your docker was actually running.

Given that everything is stuck in the docker host and only accessible through services running within the docker I can’t see any particularly nice solutions apart from installing locally. I’m looking to start developing under Docker myself so happy to hear if you come up with anything better, or maybe someone else will chime in.

Tom.

I posted this elsewhere so I hope it doesn’t look like I’m spamming :slight_smile:

I just recently got VSCode working within Docker - and intellisense and code completion seem to work very well. Here’s the repo where I pushed an example, which can help you get started:

This is using https://github.com/codercom/code-server - it lets you run VSCode within Docker itself and interact with it via the browser (much like you would a Jupyter notebook, but much better).

1 Like

That’s a super interesting approach. Reminds me of cloud9 (not part of AWS).

Preferably, I’d still like to find an approach to working with Docker in the normal fashion but with all the intellisense/code-completion bits so that I can keep my image as lean as possible.