https://coder.com/docs/code-server/install

脚本安装

curl -fsSL https://code-server.dev/install.sh | sh

配置文件位置为.config/code-server/config.yaml,可以进行一些配置例如

bind-addr: 0.0.0.0:8080
auth: password
password: YOURPSW
cert: /root/.ssl/example.com/fullchain.pem
cert-key: /root/.ssl/example.com/privkey.pem

然后就可以启动了

sudo systemctl enable --now code-server@$USER

查看状态:

sudo systemctl status code-server@$USER

重启:

sudo systemctl restart code-server@$USER

卸载:

systemctl stop code-server@$USER
systemctl disable code-server@$USER
sudo rm /etc/systemd/system/[email protected]

sudo apt remove code-server

更新:安装再重启。

容器安装

不推荐。尽管能够通过启动参数来添加不同的环境插件,但是可能因为网络等各种原因启动很慢。如果容器加载完之后进去手动安装,那每次启动容器还得操作一遍。

# This will start a code-server container and expose it at http://127.0.0.1:8080.
# It will also mount your current directory into the container as `/home/coder/project`
# and forward your UID/GID so that all file system operations occur as your user outside
# the container.
#
# Your $HOME/.config is mounted at $HOME/.config within the container to ensure you can
# easily access/modify your code-server config in $HOME/.config/code-server/config.json
# outside the container.
mkdir -p ~/.config
docker run -it --name code-server -p 127.0.0.1:8080:8080 \
  -v "$HOME/.local:/home/coder/.local" \
  -v "$HOME/.config:/home/coder/.config" \
  -v "$PWD:/home/coder/project" \
  -u "$(id -u):$(id -g)" \
  -e "DOCKER_USER=$USER" \
  codercom/code-server:latest

添加微软官方仓库

https://www.rehiy.com/post/594/
修改/usr/lib/code-server/lib/vscode/product.json 文件然后重启。

"linkProtectionTrustedDomains": [
  "https://open-vsx.org",
  "https://marketplace.visualstudio.com"
],
"extensionsGallery": {
  "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
  "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
  "itemUrl": "https://marketplace.visualstudio.com/items",
  "controlUrl": "",
  "recommendationsUrl": ""
},