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
A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.
Rules:
Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.
No spam posting.
Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.
Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.
Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).
No trolling.
Resources:
Any issues on the community? Report it using the report flag.
Questions? DM the mods!
You can also map different ports to the container. For sake of argument lets say qtorrent had a fixed port you cannot change, that’s just what the application listens to. You can then map a different container port to that application port.
tldr, OP, you can’t have two containers in docker on the same container port
Fair enough, but OPs problem can be solved by changing a 0 to a 1 in a single file.
how haha
Right, my bad for the misleading/wrong title. This is my question - how do i map a port to a container that uses network_mode: …