Skip to content

Homelab - Online Code Editor code-server

code-server is a browser-based version of VS Code. The advantage over the desktop version is that you can code online with any device, including devices like smartphones and tablets that cannot directly install VS Code.

Deployment (Docker Compose)

First, create a compose.yaml file and paste the following content:

version: "2.1"
    container_name: ${STACK_NAME}_app
      - ${APP_PORT}:8443
      - ${STACK_DIR}/config:/config
    environment: # Need to run as root to read other docker directories or host root directory
      - PUID=0
      - PGID=0
      - TZ=Asia/Shanghai
      - PASSWORD=${APP_PASSWORD} #optional
      #- SUDO_PASSWORD_HASH= #optional
      #- #optional
      #- DOCKER_MODS=linuxserver/mods:code-server-python3 #optional, if you want to add a python environment
    restart: unless-stopped

(Optional) It is recommended to create a .env file in the same directory as compose.yaml and customize your environment variables. If you don't want to use environment variables, you can directly customize your parameters in compose.yaml (e.g., replace ${STACK_NAME} with code-server).

STACK_DIR=xxx # Custom project storage path, e.g., ./code-server
DATA_DIR_LOCAL=xxx # Custom mount local directory, e.g., /DATA

# code-server
APP_PORT=xxxx # Custom access port, choose one that is not occupied
APP_PASSWORD=xxx # Login password
APP_SUDO_PASSWORD=xxx # Superuser password

Finally, execute the command docker compose up -d in the same directory as compose.yaml to start the orchestrated container.

Configuration Instructions

Configure git

After installation, if you need to use Git and initialize the configuration for username and email, please refer to the article Git Learning Notes.

Read and write permission issues

If you encounter an Error: EACCES: permission denied error when operating files, you can open the terminal and enter the following command to grant ownership to the current user:

sudo chown -R username folder_path

For example, the following command grants ownership of the current directory to the user abc:

sudo chown -R abc .

Setting the root account password

If you need to use the root account, you can initialize its password using the following command:

sudo passwd root

References and Acknowledgements

Original: This post is protected by CC BY-NC-SA 4.0 agreement, should be reproduced with attribution.

This post is translated using ChatGPT, please feedback if any omissions.