【问题标题】:Open port for docker container connected by VPN container为通过 VPN 容器连接的 docker 容器打开端口
【发布时间】:2020-10-18 06:17:47
【问题描述】:

我想通过 VPN 运行 docker 容器 (kmb32123/youtube-dl-server) 以访问受地理限制的内容。我找到了一个合适的 VPN docker 镜像 (ilteoood/docker-surfshark)。我正在尝试将这两个图像组合在一个 docker-compose.yml 文件中。但是,由于选项冲突,我无法发布 youtube-dl-server 的端口。

conflicting options: port publishing and the container type network mode

是否有另一种方法让youtube-dl-server 通过docker-surfshark 容器路由流量,同时仍然在本地公开端口8080,以便我可以访问它?

version: "2"

services: 
  surfshark-uk:
    image: ilteoood/docker-surfshark
    container_name: surfshark
    environment: 
        - SURFSHARK_USER=foo
        - SURFSHARK_PASSWORD=bar
        - SURFSHARK_COUNTRY=uk
        - CONNECTION_TYPE=udp
    cap_add: 
        - NET_ADMIN
    devices:
        - /dev/net/tun
    restart: unless-stopped
  youtube-dl-uk:
    image: "kmb32123/youtube-dl-server"
    container_name: yt-download-uk
    network_mode: container:surfshark-uk
    depends_on:
      - surfshark-uk
    ports:
      - 8080:8080
    volumes:
      - /Users/greg/Desktop/ukvids:/youtube-dl
    restart: unless-stopped
greg@computer docker $ docker-compose up
WARNING: Found orphan containers (surfshark, 949001ea6405_yt-download-uk) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
Creating surfshark-uk ... done
Creating yt-download-uk ... error

ERROR: for yt-download-uk  Cannot create container for service youtube-dl-uk: conflicting options: port publishing and the container type network mode

ERROR: for youtube-dl-uk  Cannot create container for service youtube-dl-uk: conflicting options: port publishing and the container type network mode
ERROR: Encountered errors while bringing up the project.

【问题讨论】:

    标签: docker docker-compose vpn


    【解决方案1】:

    我认为在surfshark-uk 容器中发布端口将与youtube-dl-uk 完成相同的工作,因为它使用surfshark-uk 的网络。因此,当您尝试点击该端口时,您的主机上将可以访问该端口

    curl localhost:8080
    yt-download-uk   | 172.26.0.1 - - [28/Jun/2020 02:03:17] "GET / HTTP/1.1" 404 720
    

    所以更新 docker-compose 文件,它应该可以工作了。

      surfshark-uk:
        image: ilteoood/docker-surfshark
        container_name: surfshark
        ports:
          - 8080:8080
    

    端口转发发生在 VPN 容器上,而不是那个 重用其 IP 堆栈。

    port publishing and the container type network mode

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-12
      • 1970-01-01
      • 2017-05-19
      • 1970-01-01
      • 1970-01-01
      • 2021-02-03
      • 2021-05-13
      • 2021-05-22
      相关资源
      最近更新 更多