安装 server 版 vscode
1. 直接上 docker-compose
version: '3'
services:
vscode:
container_name: vscode
hostname: anywhere
image: codercom/code-server:latest
volumes:
# - "./work:/home/coder/project"
- "work:/home/coder"
- "/etc/localtime:/etc/localtime:ro"
# 国内服务器最好换下源
# sed -i 's#http://deb.debian.org#https://mirrors.163.com#g' /etc/apt/sources.list
environment:
# web登录时候需要输入的密码
- PASSWORD=fuck
#ports:
# - "8080:8080"
networks:
nginx_imnet:
ipv4_address: 10.10.10.250
volumes:
work:
driver: local
# 引用自定义网络,可不设置
networks:
nginx_imnet:
external: true
2. 配置 nginx 反代
server {
listen 80;
listen [::]:80;
server_name code.example.com code.example.org;
location /code/ {
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
# 此处是docker的内部地址,因为我的nginx也跑在docker中
proxy_pass http://10.10.10.250:8080/;
}
}