Skip to content

Docker部署最纯粹的V2Ray

参考这里:https://toutyrater.github.io/app/docker-deploy-v2ray.html

安装docker

apt install -y docker.io
systemctl enable docker
systemctl start docker

执行 – 一行到底

mkdir -p /data/v2ray; cd /data/v2ray
UUID=162dfc96-xxxx-49c03876398e
cat > config.json <<EOF
{
  //"log": {
  //"loglevel": "debug",
  //"access": "/etc/v2ray/access.log", // 这是 Linux 的路径
  //"error": "/etc/v2ray/error.log"
  //},
  "inbounds": [{
    "port": 65432,           //此处为安装时生成的端口,可修改随意,但是保证和下面提到的端口号相同
    "listen":"0.0.0.0",
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "${UUID}", //此处为安装时生成的 id
          "alterId": 0      //此处为安装时生成的 alterId
        }
      ]
    },
    "streamSettings": {
      "network": "tcp"
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "direct"
      }
    ]
  }
}
EOF


docker run -d \
  --name v2ray \
  --restart always \
  -e TZ=Asia/Shanghai \
  -v $(pwd):/etc/v2ray \
  -p 65432:65432 \
  v2fly/v2fly-core v2ray -config=/etc/v2ray/config.json

docker logs -f v2ray

# docker start v2ray
# docker stop v2ray
# docker logs v2ray
# docker restart v2ray

客户端配置

- name: "v2_target_host"
  type: vmess
  server: x.x.x.x # 可修改
  port: 65432 # 可修改
  uuid: 0107cab3-cf00-4ec6-b613-cba7b99be210 # 可修改
  alterId: 0
  cipher: auto
  # tls: false
  network: tcp
  # ws-path: N/A
  # Host: N/A
  skip-cert-verify: true     #默认false

查看docker内的log

docker exec  v2_hone tail -f /var/log/v2ray/access.log

Leave a Reply

Your email address will not be published.