0

简短的故事,我没有来自我的互联网提供商的静态 IP,然后我想到了使用 Raspberry Pi 4、Raspbian 和 linuxserver.io Wireguard 映像构建我自己的 VPN 服务器。然后,在这些 VPN 后面是 Nextcloud 脚本。到目前为止,我已经使用 docker-compose.yaml 完成了此操作,但返回错误:

version: '3.7'

services:
  wireguard:
    privileged: true
    image: ghcr.io/linuxserver/wireguard
    container_name: wireguard
    restart: unless-stopped
    networks:
      - backbone
    volumes:
      - './wireguard/config:/config'
      - '/lib/modules:/lib/modules'
    environment:
      - PUID=1000
      - PGID=1000
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv6.conf.all.disable_ipv6=0

  nextcloud:
    privileged: true
    depends_on:
      - wireguard
    image: ghcr.io/linuxserver/nextcloud
    container_name: nextcloud
    network_mode: service:wireguard
    restart: unless-stopped
    environment:
      - PUID=1000
      - PGID=1000
    volumes:
      - ./nextcloud/config:/config
      - ./nextcloud/data:/data
    ports:
      - 8080:80

networks:
  backbone:
    driver: bridge

当我访问http://my.vpn.ip:8080时,我希望我的 nextcloud web ui 可以通过我的 VPN IP 地址从外部访问

network_mode: service:wireguard我在我的 docker-compose.yaml 文件中添加了一行,这样 nextcloud 容器将与wireguard 容器在同一个网络中。但它似乎不适用于我已经设置的暴露端口 8080:80。当我启动时docker-compose up -d,它返回如下错误输出:

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

如果有人可以帮助我,我将不胜感激。谢谢你。

4

1 回答 1

1

你必须在wireguard容器上设置端口转发,根据nextcloud镜像的标准端口。在本例中为 8080:80 和 443:443。一个例子:

version: '3.7'

services:
  wireguard:
    privileged: true
    image: ghcr.io/linuxserver/wireguard
    container_name: wireguard
    restart: unless-stopped
    networks:
      - backbone
    volumes:
      - './wireguard/config:/config'
      - '/lib/modules:/lib/modules'
    environment:
      - PUID=1000
      - PGID=1000
    cap_add:
      - NET_ADMIN
      - SYS_MODULE
    ports:
      - 8080:80 #nextcloud https webgui
      - 443:443 #nextcloud http webgui
    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1
      - net.ipv6.conf.all.disable_ipv6=0

  nextcloud:
    privileged: true
    depends_on:
      - wireguard
    image: ghcr.io/linuxserver/nextcloud
    container_name: nextcloud
    network_mode: service:wireguard
    restart: unless-stopped
    environment:
      - PUID=1000
      - PGID=1000
    volumes:
      - ./nextcloud/config:/config
      - ./nextcloud/data:/data


networks:
  backbone:
    driver: bridge

于 2020-12-19T22:37:39.047 回答