How to install code server and how to configure it

Code server is a VS Code instance that we can deploy in one machine, on this time we will use docker to deploy and configure it. If you want to know more about it you can visit the project page https://github.com/coder/code-server/blob/main/docs/FAQ.md
Pre requisites:
- Docker installed on the environment.
- Docker Compose installed the environment.
- A Machine with a Linux SO.
Well let's start, the first thing that we need to do is create a Docker compose file configuration we will use this configuration:
version: '3'
services:
code-server:
image: lscr.io/linuxserver/code-server:latest
volumes:
- ./config:/config
container_name: code-server
restart: unless-stopped
ports:
- 8443:8443
environment:
PUID: 1000
PGID: 1000
TZ: ${TIME_ZONE}
HASHED_PASSWORD: ${HASHED_PASSWORD} #optional
SUDO_PASSWORD_HASH: ${SUDO_PASSWORD_HASHED} #optional
The name of the file should be docker-compose.yml.
After that we need to create the file that contains the environment variables it will be called .env (you can use vim or nano to create the file) and the content will be:
TIME_ZONE=America/La_Paz
This configuration is the basic configuration we'll add more configuration later.
Configuration explanation:
- TIME_ZONE: It is the time zone for configure the terminal date and time in the example the terminal will use a UTC-04 time zone.
The next step is the password generation for web access and for sudo permissions.
1. Generate the web access password usingecho -n "my_web_password" | npx argon2-cli -e
After the command finished we can see a response like this
$argon2i$v=19$m=4096,t=3,p=1$wst5qhbgk2lu1ih4dmuxvg$ls1alrvdiwtvzhwnzcm1dugg+5dto3dt1d5v9xtlws4
On the next step add the hashed password to the .env file
TIME_ZONE=America/La_Paz
HASHED_PASSWORD="$argon2i$v=19$m=4096,t=3,p=1$wst5qhbgk2lu1ih4dmuxvg$ls1alrvdiwtvzhwnzcm1dugg+5dto3dt1d5v9xtlws4"
Be careful when you add the hashed password, you need to add it between quotes.2. Generate the sudo password using
echo -n "my_sudo_password" | npx argon2-cli -e
The command generates another hashed password
$argon2i$v=19$m=4096,t=3,p=1$wst5qh2gk2lu1ih4dmuxvg$ls1alrvdiwtvzhwnzcm1dugg+5dto3dt1d5v9xtlws5
And you need to add it to the .env file again, the .env file should looks like this
TIME_ZONE=America/La_Paz
HASHED_PASSWORD="$argon2i$v=19$m=4096,t=3,p=1$wst5qhbgk2lu1ih4dmuxvg$ls1alrvdiwtvzhwnzcm1dugg+5dto3dt1d5v9xtlws4"
SUDO_PASSWORD_HASHED="$argon2i$v=19$m=4096,t=3,p=1$wst5qh2gk2lu1ih4dmuxvg$ls1alrvdiwtvzhwnzcm1dugg+5dto3dt1d5v9xtlws5"
The next step is raise up the docker container using
docker-compose up
If everything is running well you can see this screen in the console

After check that we can continue entering to the GUI, we'll go to http://localhost:8443 and we can see this screen. To sign in we need to use the web password that we generated before

If your password is correct you can see the IDE screen

And that it's all, on a next post I will explain how to configure the git credentials, the user sudo and how to install and use docker inside this container.
Best Regards.
Comments ()