docker-compose安装clash

参考链接:
https://github.com/Dreamacro/clash/wiki/Running-Clash-as-a-service
https://hub.docker.com/r/dreamacro/clash
https://github.com/Dreamacro/clash-dashboard/
https://github.com/Dreamacro/clash/wiki/Configuration

有时候在家想查询一些英文技术资料,所以使用docker安装一个clash。

一、docker-compose配置

1.2 主要配置

docker-compose.yml配置如下。

  claves-clash:
    image: dreamacro/clash:v1.11.8
    container_name: claves-clash
    hostname: claves-clash
    restart: always
    ports:
      - "1080:7890"
      - "1081:7891"
      - "1082:8899"
      - "9090:9090"
    volumes:
      - ./volumes/claves-clash/config/clash.yaml:/root/.config/clash/config.yaml
      - ./volumes/claves-clash/dashboard:/ui
    deploy:
      resources:
        limits:
          cpus: '0.5'
          memory: 512M
        reservations:
          memory: 256M
    logging:
      options:
        max-size: "10240k"
        max-file: "3"
    networks:
      claves-switch:
        ipv4_address: 172.21.0.254

1.2 dashboard打包

打包dashboard文件后,放置在./volumes/claves-clash/dashboard目录。

打包命令:

npm install -g pnpm
pnpm install
pnpm build

1.3 yml配置

yml文件,需要注意external-ui配置项目。

# A relative path to the configuration directory or an absolute path to a
# directory in which you put some static web resource. Clash core will then
# serve it at `http://{{external-controller}}/ui`.
external-ui: /ui