v2fly / docker

docker build repo for v2fly
https://hub.docker.com/r/v2fly/v2fly-core
MIT License
753 stars 215 forks source link

请求帮助,想使用docker compose创建但是报错。 #46

Closed lhbdhr closed 1 year ago

lhbdhr commented 1 year ago

使用docker run可以运行,但compose可以修改端口等配置信息,很方便,所以还是想用compose,但是报错。

# docker run -d --name v2ray -v $PWD/config.json:/etc/v2fly/config.json -v $PWD/ca:/etc/v2fly/ca -p 443:443 v2fly/v2fly-core run -c /etc/v2fly/config.json
# docker-compose.yaml

version: '3.9'

services:
  v2ray:
    image: v2fly/v2fly-core
    container_name: v2ray
    restart: unless-stopped
    ports:
      - '443:443'
    volumes:
      - $PWD/config.json:/etc/v2fly/config.json
      - $PWD/ca:/etc/v2fly/ca/
      - $PWD/logs:/etc/v2fly/logs/
    command:
      - /usr/bin/v2ray run -c /etc/v2fly/config.json

{
  "log": {
    "loglevel": "error",
    "access": "/etc/v2fly/logs/access.log",
    "error": "/etc/v2fly/logs/error.log"
  },
  "inbounds": [
    {
      "port": 443,
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "xxxxxxxxxxxx",
            "level": 0,
            "alterId": 0,
            "email": "love@v2fly.com"
          }
        ]
      },
      "streamSettings": {
        "network": "tcp",
        "security": "tls",
        "tlsSettings": {
          "certificates": [
            {
              "certificateFile": "/etc/v2fly/ca/server.cer",
              "keyFile": "/etc/v2fly/ca/server.key"
            }
          ]
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom"
    }
  ]
}

container 不能正常启动。 docker logs 报错信息:

v2ray /usr/bin/v2ray run -c /etc/v2fly/config.json: unknown command
Run 'v2ray help /usr/bin/v2ray run -c' for usage.

尝试过修改command,v2ray help都不能正常打印。

kslr commented 1 year ago
/usr/bin/v2ray run -c /etc/v2fly/config.json
run -c /etc/v2fly/config.json
lhbdhr commented 1 year ago
/usr/bin/v2ray run -c /etc/v2fly/config.json
run -c /etc/v2fly/config.json

command修改成run -c /etc/v2fly/config.json吗? 尝试过了,不行。

v2ray run -c /etc/v2fly/config.json: unknown command
Run 'v2ray help run -c' for usage.
# command里无论填写什么 都会有个v2ray打头,然后提示  unknown command
例如:
command:
      - ls
# 提示
v2ray ls: unknown command
Run 'v2ray help' for usage.
kslr commented 1 year ago

v2 镜像拉的是最新的马

lhbdhr commented 1 year ago

是最新的呀,昨天全新机器,刚pull的

Hzend commented 1 year ago

修改一下docker-compose.yml文件

    command:
      - /usr/bin/v2ray run -c /etc/v2fly/config.json

修改为

    command: run -c your_config_path/config.json
lhbdhr commented 1 year ago

修改一下docker-compose.yml文件

    command:
      - /usr/bin/v2ray run -c /etc/v2fly/config.json

修改为

    command: run -c your_config_path/config.json

牛的,可以了,这是什么原理啊?

lhbdhr commented 1 year ago

问题已解决!感谢各位。

JacksonRGB commented 1 year ago

我今天也遇到了 unknown command,按照上面修改还是不行

proxy | v2ray run -c /etc/v2ray/config.json: unknown command proxy | Run 'v2ray help run -c' for usage.

container_name: proxy
image: v2fly/v2fly-core:v5.1.0
volumes:
  - $PWD/v2ray-config.json:/etc/v2ray/config.json
command:
  - "run -c /etc/v2ray/config.json"
lhbdhr commented 1 year ago

我今天也遇到了 unknown command,按照上面修改还是不行

proxy | v2ray run -c /etc/v2ray/config.json: unknown command proxy | Run 'v2ray help run -c' for usage.

container_name: proxy
image: v2fly/v2fly-core:v5.1.0
volumes:
  - $PWD/v2ray-config.json:/etc/v2ray/config.json
command:
  - "run -c /etc/v2ray/config.json"

修改成这样,命令语句 和 command 必须在一行,而且别加双引号。

command: run -c /etc/v2fly/config.json