Install vscode (visual studio code) as a separate docker container

I am running my home-assistant (not HassIO) as a docker container and wanted to install vscode. Here is what I did.

  1. create local folders to hold vscode config data

mkdir /vscode

  1. install docker container
    docker run --name vscode --restart unless-stopped -p 8443:8443 -itd -v /vscode:/config -v /path_to_hass_config_folder:/config/workspace -e ‘TZ=Australia/Adelaide’ -e PASSWORD=xxx -e SUDO_PASSWORD=xxx linuxserver/code-server

  2. log into vscode web-ui on http://ip:8443. you should be able to see all your hass config files. At this point, we have a working code editor.

  3. However to make it similar to hassio extension, with all those autofill bells and whistles, we need to install a few extensions. I fetched the list from the official addon here.

emilast.LogFileHighlighter
ESPHome.esphome-vscode
keesschollaart.vscode-home-assistant
lukas-tr.materialdesignicons-intellisense
oderwat.indent-rainbow
redhat.vscode-yaml
usernamehw.errorlens
vscode-icons-team.vscode-icons

for some reason I am unable to search for them with in vscode web-ui. so I downloaded vsix files and install them manually. here is how I did it.

a) goto vscode market place and search for the above extensions, one at a time, and download them.
b) move those vsix files to vscode config folder
c) In the vscode web-ui, click on hamburger icon (top left) > view > extensions
d) in the extensions side bar click the 3 dots (’…’) and click “install from vsix”. under /config select and install the extensions, one by one.

  1. close the vscode web-ui (browser) and reopen it.
  2. In order to provide home-assistant access to vscode, in the settings, search for home assistant and provide url (http://ip:8123) and a long lived token.
  3. similarly you need to provide esphome url (http://ip:6052) as well.

hope this helps someone.

7 Likes

What does this provide that the normal VSCode extension doesn’t?

I think that’s the point. vscode is available as an add-on for hass.io, but add-ons aren’t available for a standard HA docker install. That’s what I understood anyway, but then I’ve not had much coffee today so…

1 Like

I just installed VS Code in a docker container via docker-compose. I used this site as reference: (Thanks to whomever posted this)

My question is: Is there a way to load the Home Assistant Extension for VS Code with this type of configuration? I could figure it out.

UPDATE:
Found my own answer after a while … I didn’t realize that you could download these extensions and then import it via “Install from VSIX”

1 Like

I don’t run hassio (just normal docker HA), and I have VSCode extension installed on VSCode. It connects to my HA and I get all the features.

So what I’m trying to figure out is what the add-on provides that the extension doesn’t. If it’s just a web browser version of VSCode, then cool. But if they are looking for just using normal VSCode with HA, the add-on/vscode server isn’t needed.

1 Like

@flamingm0e
in your case, I think you are all set. I didn’t want to install and maintain vscode on each machine separately.

So what you’re saying is that it’s a web version of vscode? How hard is it to say that?

Thank you very much. Added this also in the side panel of my home assistant and works like a charm :slight_smile:

1 Like

I’ve added the link to VS Code in the HA side panel but when I access it from there it doesn’t show the HA workspace like it does just going directly to the VS Code URL in the browser.

Is there a trick I’m missing to get it working?

1 Like

I got the same problem. It resets to blank and you have to open recent workspace again.

1 Like

@Clubke @finity

I fixed the instructions to correct this issue. please try again. thanks.

In my setup the port 8443 is used by Ubiquti Unifi.

@mcarty
you can map it any port. for example 8222 like below

-p 8222:8443

Works like a charm now :slight_smile:

Hi,
Which container do you use for VSCode?
Using VSCode on Synology registry, I find tons of versions
Your help will be appreciated, thanks

Is is codercom/code-server?

no, its linuxserver/code-server

How do I get a HA side panel working ? Can you please provide your config for that. Thanks

Thanks for your guide.

I only have one problem:
I’m trying to install those VSIX files but every time I install one it only says:
“Please reload Visual Studio Code to complete installing the extension Python.”

And the actual extension doesn’t get installed.
I already tried restarting and refreshing everything but it just doesn’t work.
Any ideas?

Thanks a lot.

Hi hello

thanks

but i dont know why, cant connect do VS vis ip: 8443

i do have this in log :

standard_init_linux.go:211: exec user process caused "exec format error"

Thanks in advance