jesusjsc

使用docker简单部署v2ray
# 使用docker简单部署v2ray --- ## 关于docker/docker-compose如...
扫描右侧二维码阅读全文
09
2019/06

使用docker简单部署v2ray

使用docker简单部署v2ray


关于docker/docker-compose如何安装

请参考docker官方文档:

关于v2ray是什么

请参考:V2Ray官网

项目目录

v2ray/
├── config.json
└── docker-compose.yml

0 directories, 2 files
  • 其中config.jsonv2ray的配置文件。配置文件可以自己写,也可以用在线工具生成:V2Ray配置生成器

    如下为config.json的例子。

{
    "log": {
        "access": "",
        "error": "",
        "loglevel": "warning"
    },
    "inbounds": [
        {
            "port": 5233,
            "protocol": "vmess",
            "settings": {
                "udp": true,
                "clients": [
                    {
                        "id": "e2d9518d-b0e6-cb21-4393-d6a0cd822855",
                        "alterId": 100,
                        "email": "[email protected]"
                    }
                ]
            }
        },
        {
            "port": 5234,
            "protocol": "vmess",
            "settings": {
                "clients": [
                    {
                        "id": "1d367ee2-5540-2ccb-9d35-7ab54e054c75",
                        "alterId": 100,
                        "email": "[email protected]"
                    }
                ]
            },
            "streamSettings": {
                "network": "ws"
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls"
                ]
            }
        },
        {
            "tag": "tg-in",
            "port": 6666,
            "protocol": "mtproto",
            "settings": {
                "users": [
                    {
                        "secret": "11111111222222223333333344444444"
                    }
                ]
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom",
            "settings": {}
        },
        {
            "protocol": "freedom",
            "settings": {},
            "tag": "direct"
        },
        {
            "protocol": "blackhole",
            "settings": {},
            "tag": "blocked"
        },
        {
            "protocol": "mtproto",
            "settings": {},
            "tag": "tg-out"
        }
    ],
    "dns": {
        "server": [
            "1.1.1.1",
            "1.0.0.1",
            "8.8.8.8",
            "8.8.4.4",
            "localhost"
        ]
    },
    "routing": {
        "domainStrategy": "IPOnDemand",
        "rules": [
            {
                "type": "field",
                "inboundTag": ["tg-in"],
                "outboundTag": "tg-out"
            }
        ]
    }
}
  • 其中docker-compose.yml文件如下:
version: "3.1"

services:

  app:
    image: v2ray/official
    container_name: v2ray_app
    volumes:
      - "./config.json:/etc/v2ray/config.json"
      - "/etc/localtime:/etc/localtime"
    ports:
      - "5233:5233"
      - "127.0.0.1:5234:5234"
      - "6666:6666"
    restart: always
* 这里请将`config.json`替换成你自己的配置文件
* 关于端口映射,可以自己调整为自己想要使用的端口
* 端口`5233:5233`的意思是,将宿主机的5233端口映射到容器内的5233端口
* 端口`127.0.0.1:5234:5234`的意思是,将宿主机的5234端口映射到容器内的5234端口,外网不可访问,只能本地访问
* 端口`6666:6666`的意思是,将宿主机的6666端口映射到容器内的6666端口,这里用于创建电报代理`mtproto`

常用命令

  • 部署 v2ray: docker-compose up -d
  • 启动 v2ray: docker-compose start v2ray
  • 停止 v2ray: docker-compose stop v2ray
  • 重启 v2ray: docker-compose restart v2ray
  • 删除 v2ray: docker stop v2ray && docker rm v2ray
  • 更新 v2ray: docker-compose pull && docker-compose up -d
Last modification:June 9th, 2019 at 05:17 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment