![](/img/trans.png)
[英]How to share data between host and containers using volumes in Docker Compose
[英]How do I share host volumes between containers in docker-compose?
我在这里做错了什么? pia-shared 没有安装在 qbittorrent 容器中,但我可以在 vpn 容器中看到它?
我需要每次 vpn 连接时更改的端口号并存储在 port.dat 中以在 qbittorrent 容器中使用。 理想情况下,我不想修改容器以使升级更容易,并且 qbt (qbittorrent-cli) 已安装在 qbittorrent 容器中。
version: '3.3'
services:
vpn:
image: thrnz/docker-wireguard-pia
volumes:
- ./pia:/pia
- pia-shared:/pia-shared
ports:
- 6881:6881
- 6881:6881/udp
- 8080:8080
cap_add:
- NET_ADMIN
- SYS_MODULE
devices:
- /dev/net/tun:/dev/net/tun
environment:
- LOC=uk
- USER=xxxxxxx
- PASS=xxxxxxx
- LOCAL_NETWORK=192.168.1.0/24
- KEEPALIVE=25
- VPNDNS=8.8.8.8,8.8.4.4
- PORT_FORWARDING=1
- WG_USERSPACE=1
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
- net.ipv6.conf.default.disable_ipv6=1
- net.ipv6.conf.all.disable_ipv6=1
- net.ipv6.conf.lo.disable_ipv6=1
healthcheck:
test: ping -c 1 www.google.com || exit 1
interval: 30s
timeout: 10s
retries: 3
qbittorrent:
image: lscr.io/linuxserver/qbittorrent
container_name: qbittorrent
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/London
- WEBUI_PORT=8080
volumes:
- ./qbittorrentConfig:/config
- ../downloads:/downloads
- pia-shared:/pia-shared
qbitorrent-setup:
image: lscr.io/linuxserver/qbittorrent
depends_on:
- qbittorrent
restart: "no"
entrypoint: [ "bash", "-c", "sleep 10 && qbt server settings connection --listen-port \"$$(</pia-shared/port.dat)\""]
network_mode: 'service:vpn'
volumes:
- pia-shared:/pia-shared
volumes:
pia:
pia-shared:
config:
downloads:
我通过删除卷并让 docker 重新创建它来解决这个问题。 我不需要对 docker-compose.yml 进行任何更改。
我已经逐渐完善了 docker-compose.yml,首先为 vpn 创建它,然后开始添加其他容器,这一定会以某种方式混淆它。
docker volume ls
docker volume rm wiregaurd-pia_pia-shared
docker-compose up
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.