Use Clash on Docker

在docker上部署clash

01 docker-compose编写

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
services:
  # Clash
  clash:
    image: centralx/clash:1.18.0
    container_name: clash
    volumes:
      - ./config.yaml:/home/runner/.config/clash/config.yaml
    ports:
      - "7890:7890/tcp"
      - "7890:7890/udp"
      - "9090:9090"
      - "8181:80"
    restart: always
    environment:
      - SET_CONTAINER_TIMEZONE=true
      - CONTAINER_TIMEZONE=Asia/Shanghai
      - TZ=Asia/Shanghai

02 配置文件 config.yaml

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
xed-port: 7890
# 添加配置项
allow-lan: true
mode: rule
log-level: info
# 添加配置项
external-controller: '0.0.0.0:9090'
# 添加配置项
secret: 'yourpass'
dns:
  enable: false
  ipv6: false
  default-nameserver: [223.5.5.5, 119.29.29.29]
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16
  use-hosts: true
  nameserver: ['https://doh.pub/dns-query', 'https://dns.alidns.com/dns-query']
  fallback: ['https://doh.dns.sb/dns-query', 'https://dns.cloudflare.com/dns-query', 'https://dns.twnic.tw/dns-query', 'tls://8.8.4.4:853']
  fallback-filter: { geoip: true, geoip-code: CN, ipcidr: [240.0.0.0/4, 0.0.0.0/32] }
proxies:
  ...

03 启动

1
docker-compose up -d
Licensed under CC BY-NC-SA 4.0