Hi there!
I’m trying to set up two services (through docker) both of which use port 8080 by default. However I am wanting these to services to sit behind a VPN using Gluetun. I added both of the ports I want to use to the compose file, but this just leads to only one of the services working as the other one will say “port already in use”. How can I strictly tell these services what port they shall use in the compose file?
This is how I did it so far;
docker-compose.yml
---
version: '3'
services:
vpn:
image: qmcgaw/gluetun:latest
container_name: vpn
restart: unless-stopped
cap_add:
- NET_ADMIN
environment:
- VPN_SERVICE_PROVIDER=custom
- VPN_TYPE=wireguard
- VPN_ENDPOINT_IP=####
- VPN_ENDPOINT_PORT=####
- WIREGUARD_PUBLIC_KEY=####
- WIREGUARD_PRIVATE_KEY=####
- WIREGUARD_PRESHARED_KEY=####
- WIREGUARD_ADDRESSES=####
devices:
- /dev/net/tun:/dev/net/tun
ports:
- '8080:8080'
#VPN
- 8888:8888/tcp
- 8388:8388/tcp
- 8388:8388/udp
- 8000:8000/tcp
- 8584:8584
- 8585:8585
volumes:
- /docker/appdata/gluetun:/gluetun
sabnzbd:
image: lscr.io/linuxserver/sabnzbd:latest
container_name: sabnzbd
network_mode: container:vpn
volumes:
- /docker/appdata/sabnzbd/data:/config
restart: unless-stopped
qbittorrent:
container_name: qbittorrent
image: linuxserver/qbittorrent:latest
restart: unless-stopped
network_mode: container:vpn
volumes:
- /docker/appdata/qbitorrent:/config
It doesn’t look like you’ve specified any ports for the qbit container, each service needs a ports section. You can map ports to different system ports by just changing the first number.
External Port : internal port / (tcp/udp) ie 8081:8080/tcp
Not when using:
network_mode: container:vpn
, then you cant use ports section. Am hosting the port via Gluetun, then forcing the container to use Gluetun as network.Ahh gotcha, sorry I’m viewing on sync where post level code blocks are broken haha
You could join two different networks
And bind the port to that.
Example:
ports: - 8880:8880 #HTTP port #optional - 8443:8443 #HTTPS port - 3478:3478/udp - 10001:10001/udp - 8080:8080 - "10.0.0.253:1900:1900/udp" #optional - 8843:8843 #optional - 6789:6789 #optional - 5514:5514/udp #optional networks: service: net: ipv4_address: 10.0.0.253
In that case I binded the container to the service network but needed a static IP reachable by outside devices.
So I created a macvlan adapter, binded the port 1900 to that adress and all was fine.
Should probably work for your use case.Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:
Fewer Letters More Letters HTTP Hypertext Transfer Protocol, the Web HTTPS HTTP over SSL IP Internet Protocol SSL Secure Sockets Layer, for transparent encryption VPN Virtual Private Network
4 acronyms in this thread; the most compressed thread commented on today has 10 acronyms.
[Thread #213 for this sub, first seen 12th Oct 2023, 16:55] [FAQ] [Full list] [Contact] [Source code]
Just use a different port number. I’m not sure why it’s necessary to use the same one since you can change qbittorrent’s port in the config files.
Sorry that was my question, dont want to use the port twice, I want to tell the compose file what to use for each container, but I dont know how.
- Fixed the title, mb
Ah, well the qbittorrent config file should live in the directory you mapped to /config. I think you can pull the default one and edit it for your container.