Docker - Visual Studio Code Server Setup


Here I describe my setup of the Visual Studio Code Server container.

I run this Docker container on a Ubuntu VM that runs via [[ Proxmox VE ]]. I perform the following on the CLI.

Since I use vs code server to edit yaml files of Home Assistant I have created a volume mapping to the configuration folder of Home Assistant

Docker pull command:

docker pull linuxserver/codeserver

Within my home folder I have created a Docker folder where I create a subfolder for each container:

cd ~
mkdir -p docker/codeserver
cd docker/codeserver

Also create a folder where the config files can be stored:

mkdir config

I use the Nano text editor to create a shell script:

sudo nano codeserver_run.sh

With this shell script we are going to create the container. Copy the following into codeserver_run.sh:

IDu=$(id -u $(logname)) # Saves the logged in user id in the IDu variable
IDg=$(id -g $(logname)) # Saves the logged in user group in the IDg variable

docker run -d \
 --name=codeserver \
 --hostname=codeserver \
 -p 8833:8443 \
 -v $PWD/config:/config \
 -v /home/USER/docker/homeassistant/config:/homeassistant \
 -v /etc/localtime:/etc/localtime:ro \
 -e TZ=Europe/Amsterdam \
 -e PUID=$IDu \
 -e PGID=$IDg \
 --restart unless-stopped \
 linuxserver/code-server

If necessary, adjust the following:

-p 8833:8443
Choose a port that is still available, I chose 8833. Check this with netstat

-v $PWD/config:/config
Choose the location for the code server config files. In this example it is the config map we created

-v /home/USER/docker/homeassistant/config:/homeassistant
(OPTIONAL) Create a mapping to a location with files you want to edit with code server. In this example it is the configuration folder of Home Assistant

It is also possible to set a password with the environment variable PASSWORD or HASHED_PASSWORD. See the description of the image

Exit Nano (CTRL-X) and save the changes.

Now create the container:

sudo sh codeserver_run.sh

Check if the container is running properly.

See also my notes about updating containers with Portainer or via the CLI. With Synology’s Docker Application, updating a container is also very easy.

Using Visual Studio Code Server

Visual Studio Code Server can now be accessed via the following URL:

http://<IP DOCKER HOST>:8833/

To use the mapping to the Home Assistant configuration map:

Go to File and Open Folder..., empty the command palette and type /homeassistant and press Enter. Now it is possible to edit the yaml files of Home Assistant.


Read other notes

Comments

    No comments found for this note.

    Join the discussion for this note on this ticket. Comments appear on this page instantly.

    Tags


    Notes mentioning this note


    Notes Graph