Code Monkey home page Code Monkey logo

Comments (13)

nJhEqnvK avatar nJhEqnvK commented on June 18, 2024 1
  1. config.json:ro

这个:ro是啥情况?为什么需要挂read only?

  1. 第一个问题是,我创建的nginx容器是不是要映射一下端口(-p 36363:36363),因为nginx的conf里不会是代理路由到v2ray的36363端口吗?

docker bridge 下端口可以根据喜好自由映射, 比如对nginx做-p 443:443,再对v2ray做-p 36363:36363,nginx配置里设置转发到$(v2ray_container_ip):36363但是不建议这样,因为就经验而谈bridge下的网络性能十分有限,另外现在有VLESS了可以不用nginx监听443了

  1. 第二个问题是,v2ray容器需不需要映射端口?不过不应该不能两个容器映射同一端口吧,我看他们别的v2ray的容器是没写端口映射的?

  • 不能映射到同协议下的同一端口,如nginx-p 443:443/tcp,v2ray-p 443:443/tcp则会报错端口被占用
  • 别的没写映射是因为网络采用host模式 --network host

后附个人的配置仅供参考:

docker run \
 -d \
 --cap-add=NET_ADMIN \
 --restart=always \
 --network host \
 -e V2RAY_LOCATION_CONFIG=/etc/v2ray \
 -e V2RAY_LOCATION_ASSET=/etc/v2ray \
 -e V2RAY_BUF_READV=enable \
 -v $(path_to_config):/etc/v2ray \
 -v $(path_to_logs):/var/log \
 --name v2ray \
 v2fly/v2fly-core

from docker.

Weaxs avatar Weaxs commented on June 18, 2024

谢谢orz

from docker.

kslr avatar kslr commented on June 18, 2024

一切正常

from docker.

Weaxs avatar Weaxs commented on June 18, 2024

不好意思再问下,这个v2ray的容器怎么进入orz?就是我用docker exec -i 进容器报permission denied,不好意思,最近才上手docker_(:з」∠)_

from docker.

kslr avatar kslr commented on June 18, 2024

那得看是谁 denied,试试 sudo dcoker

from docker.

Weaxs avatar Weaxs commented on June 18, 2024

哦对之后面跟的目录是/bin,应该是目录denied,不过用/bin/bash目录进容器是没有此目录no such file or directory
这个是和这个容器有关系吗orz

from docker.

kslr avatar kslr commented on June 18, 2024

sudo docker exec -ti name bash

from docker.

Weaxs avatar Weaxs commented on June 18, 2024

好像还是不行...
[root@ip-172-26-12-174 v2ray]# sudo docker exec -ti v2ray bash
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: "bash": executable file not found in $PATH": unknown
[root@ip-172-26-12-174 v2ray]# sudo docker exec -ti v2ray /bash
OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused "exec: "/bash": stat /bash: no such file or directory": unknown
谢谢哈hh没事我就是想确认下容器的config没问题,应该是没问题的,我看看是不是和nginx的配置不匹配

from docker.

kslr avatar kslr commented on June 18, 2024

这个是 Alpine 打包的,大概没有bash

from docker.

Weaxs avatar Weaxs commented on June 18, 2024

不好意思再问个问题,举例例子比如我v2ray config里面port是36363,然后v2ray和nginx都用docker两个容器启动。
第一个问题是,我创建的nginx容器是不是要映射一下端口(-p 36363:36363),因为nginx的conf里不会是代理路由到v2ray的36363端口吗?
第二个问题是,v2ray容器需不需要映射端口?不过不应该不能两个容器映射同一端口吧,我看他们别的v2ray的容器是没写端口映射的?
感谢orz

from docker.

kslr avatar kslr commented on June 18, 2024

不同模式下答案不同,你应该看文档。
我建议使用 host

from docker.

Weaxs avatar Weaxs commented on June 18, 2024

好的,我明白了orz感谢,我再去试试hh

from docker.

Weaxs avatar Weaxs commented on June 18, 2024

感谢大佬们的解答,反馈一下
之后我去看了下 docker_compose 和 VLESS 可以了,但是我没有用VLESS监听443,还是用 nginx 监听443后反向代理到 v2ray

以下是我的docker-compose文件

version: "3.8"
services: 
    nginx: 
        image: nginx:latest
        restart: always
        # ports: 
        #    - "80:80"
        #    - "443:443"
        volumes: 
            - ./nginx/conf.d:/etc/nginx/conf.d
            - ./nginx/certs:/etc/nginx/certs
        network_mode: host
        container_name: nginx

    v2ray: 
        restart: always
        depends_on:
            - nginx
        image: v2fly/v2fly-core
        volumes: 
            - ./v2fly/config.json:/etc/v2ray/config.json
            # - ./nginx/certs:/etc/v2ray/certs
        network_mode: host
        container_name: v2ray

v2ray的 config.json 用的是下面这个:

https://github.com/v2fly/v2ray-examples/blob/master/VLESS-TCP-TLS-WS%20(recommended)/config_server.json

但是去掉了监听443的部分

以上。感谢orz
@nJhEqnvK @kslr

from docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.