码迷,mamicode.com
首页 > 系统相关 > 详细

clash in docker 使用教程(Linux)

时间:2019-08-09 23:21:02      阅读:396      评论:0      收藏:0      [点我收藏+]

标签:aml   apt   多个   存在   direct   地址   name   ubuntu   container   

1. 安装软件

先安装好dockerdocker-compose,ubuntu直接使用apt

docker-compose这个软件类似于胶水的作用,相当于将文件,(多个)镜像粘合起来使用.
通过这个软件我们就可以将自己的clash配置文件链接到clash的docker镜像中使用

2. 准备配置文件

以下来自官方说明

准备两个文件放在一起,其中一个是
config.yaml
需要把这个文件替换成自己的clash配置文件,以下官网给的范例

port: 7890
socks-port: 7891

# `allow-lan` must be true in your config.yaml
allow-lan: true
external-controller: 0.0.0.0:8080

另一个是docker-compose的配置文件,无需更改,文件名必须为docker-compose.yml
注意linux下要把bridge改成host

version: '3'
services:
  clash:
    image: dreamacro/clash
    volumes:
      - ./config.yaml:/root/.config/clash/config.yaml
    ports:
      - "7890:7890"
      - "7891:7891"
      # If you need external controller, you can export this port.
      # - "8080:8080"
    restart: always
    # When your system is Linux, you can use `network_mode: "host"` directly.
    network_mode: "bridge"
    container_name: clash

其中解释一下这一行,冒号前面是本机文件的地址,冒号后面是clash镜像所使用的镜像地址,做了一个映射
./config.yaml:/root/.config/clash/config.yaml

3. 使用镜像

在两个文件同时存在的目录下,使用命令
sudo docker-compose up -d

-d表示后台启动

clash in docker 使用教程(Linux)

标签:aml   apt   多个   存在   direct   地址   name   ubuntu   container   

原文地址:https://www.cnblogs.com/CodeAndMoe/p/clash-in-docker-linux.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!