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

Hi @BikeDude. Sorry for the delay. Are you sure you looked at the right place? All images seem to be public and I just tried to pull a couple of them without issue.

HI, I would like to ask you for help regarding the correct configuration of VSCODE and DB MARIA; basically, I use Home Assistant on docker compose installed on debian. the docker-compose,yaml file does not give me errors after configuring the VSCODE file; however I can’t use vscod. I think I’m confusing when indicating the volume. I’ll copy my compose file configuration to you. by the way I created a folder called code-server in .storage Could you help me understand what I’m doing wrong. Thank you

version: ‘3.9’

services:

home-assistant:

container_name: home-assistant

image: Package home-assistant · GitHub

volumes:

  • /home/deb/homeassistant:/config

  • /run/dbus:/run/dbus:ro

environment:

  • TZ=Europe/Rome

network_mode: host

restart: always

Visual Studio code

vscode:

container_name: vscode

image: codercom/code-server:latest

restart: unless-stopped

environment:

 PASSWORD: XXXXXXXX

volumes:

 - /home/deb/homeassistant:/config

 - /home/deb/homeassistant/.storage/share/code-server

ports:

 - "7443:7443"

command: code-server --auth password --port 7443 --disable-telemetry /home/deb/homeassistant:/config

This is how I would set it up:

version: '3.7'
services:
  db:
    image: mariadb
    restart: unless-stopped
    environment:
      MARIADB_ROOT_PASSWORD: [strong pw here]
      MARIADB_DATABASE: homeassistant
      MARIADB_USER: logger
      MARIADB_PASSWORD: [strong pw here]
    volumes:
      - /srv/mariadb:/var/lib/mysql
    ports:
      - 3306:3306

  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    depends_on:
      - db
    volumes:
      - /srv/homeassistant:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    privileged: true
    network_mode: host

  code-server:
    image: lscr.io/linuxserver/code-server:latest
    container_name: code-server
    environment:
      - TZ=America/New_York
      - PASSWORD=[strong pw here]
    volumes:
      - /srv/code-server:/config
      - /srv/homeassistant:/ha ### <-- path to your ha installation
    ports:
      - 8443:8443
    restart: unless-stopped

My working test setup for home assistant, mqtt and codeserver dockers so that codeserver has access to home assistant config folder. Just set passwords and all set to go.

Add this to docker-compose.yml:

version: '3'
services:
  homeassistant:
    image: homeassistant/home-assistant:latest
    volumes:
      - /opt/homeassistant:/config
    ports:
      - "8123:8123"
    restart: unless-stopped
    networks:
      - homeassistant

  codeserver:
    image: codercom/code-server:latest
    user: 0:0
    environment:
      - PASSWORD=xxx
      - SUDO_PASSWORD=yyy
    volumes:
      - /opt/homeassistant:/config
      - /opt/codeserver:/root/.local/share/code-server
    ports:
      - "8080:8080"
    restart: unless-stopped
    networks:
      - homeassistant

  mosquitto:
    image: eclipse-mosquitto
    ports:
      - "1883:1883"
      - "9001:9001"
    volumes:
        - /opt/mosquitto/config:/mosquitto/config
        - /opt/mosquitto/data:/mosquitto/data
        - /opt/mosquitto/log:/mosquitto/log
    restart: unless-stopped
    networks:
      - homeassistant

networks:
  homeassistant:
    driver: bridge

And give this command to download and start containers:

docker compose up -d