qdm12 / gluetun

VPN client in a thin Docker container for multiple VPN providers, written in Go, and using OpenVPN or Wireguard, DNS over TLS, with a few proxy servers built-in.
https://hub.docker.com/r/qmcgaw/gluetun
MIT License
8.09k stars 374 forks source link

Export the forwaded_port to a variable #52

Closed groenator closed 5 years ago

groenator commented 5 years ago

Hi,

I am using your image with Deluge container, the downside that I have with deluge container is that I have to set the incoming port for torrenting manually. Since I have to wait for PIA image to write down the forwarded_port first, I can't set the port. After I have to port from the file I have to manually set the port in the UI and restart the container.

I tried many things to export this port to a variable and pass it to deluge, but so far I didn't have any luck. Is it possible to export the forwarded_port to a variable instead of a file? Or, at least export the port to a file and variable. If I have a variable would be easier to pass the port to other containers, such a deluge.

What is the best way to pass the port to another container, other than mounting the volume?

Thank you!

qdm12 commented 5 years ago

I can export it to an environment variable inside the PIA container but it won't be available to other containers.

Plus PIA servers decides of the forwarded port so we can't preset a variable.

The only solution is therefore to write it to file. You could bind mount it and share it across containers like that. You could modify the Deluge container to read the file at start, in example:

MYVAR=`cat /yourpath/portforwardfile`
# then write it to your deluge conf file with sed for example
groenator commented 5 years ago

Hi,

Doing what you have described it doesn't work at all. I have created a new var in my docker-compose file, which will cat the file but when I ssh into the container and run export -p. Instead of reading the port from the file it does show exactly the path of where my file is located. So for some reason, it doesn't execute my command.

export PGID='1000' export PIA_PORT='cat /forwarded_port

I have three containers running in the same docker-compose file. Creating a var to read the port from PIA container will make it easy for deluge to read the env if I use a .env file set to PIA_PORT=${PIA_PORT}, and set this in the environment section of docker-compose for deluge container.

I've tried every possibility, I can share my docker-compose file with you. If you have a better solution please let me know.

Regards,

On Tue, 8 Oct 2019 at 17:45, Quentin McGaw notifications@github.com wrote:

I can export it to an environment variable inside the PIA container but it won't be available to other containers.

Plus PIA servers decides of the forwarded port so we can't preset a variable.

The only solution is therefore to write it to file. You could bind mount it and share it across containers like that. You could modify the Deluge container to read the file at start, in example:

MYVAR=cat /yourpath/portforwardfile# then write it to your deluge conf file with sed for example

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/qdm12/private-internet-access-docker/issues/52?email_source=notifications&email_token=ABJRLJSUDJNZP42FL74NBSTQNS2I7A5CNFSM4I56B7FKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAU2VPY#issuecomment-539601599, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJRLJQBVW436EYPHIJC5H3QNS2I7ANCNFSM4I56B7FA .

qdm12 commented 5 years ago

I'm not sure what you're doing, maybe share your docker compose file? Take care of removing your credentials.

The way I would do it is

groenator commented 5 years ago

Hi,

Here is a copy of my compose file. As it shows, I am exporting the volumes and make the volumes available between containers. I will look at the entry point, do you have any guides on how to do it? Do I have to rebuild your image again?

version: '3' services: vpn: container_name: deluge_vpn image: qmcgaw/private-internet-access hostname: deluge.local restart: always ports:

qdm12 commented 5 years ago

A slightly better way would be to have a named volume as - portforward:/forwarded_port.

You need to change the entrypoint of linuxserver/deluge, you could use the entrypoint command to overwrite it in Docker Compose for your Deluge container. You'll have to dig through linuxserver's deluge image as their entrypoint seems quite hidden to me. Or use another Docker image for Deluge.

qdm12 commented 5 years ago

Please have a look at #53 it should indirectly solve the issue. I'll close here for now.

groenator commented 5 years ago

Sweet, thank you.

On Wed, 13 Nov 2019, 11:39 Quentin McGaw, notifications@github.com wrote:

Closed #52 https://github.com/qdm12/private-internet-access-docker/issues/52.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/qdm12/private-internet-access-docker/issues/52?email_source=notifications&email_token=ABJRLJRL6BME44RFVAW7WP3QTPRPXA5CNFSM4I56B7FKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOU2LXSTI#event-2794944845, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJRLJSPLT2VIO7WB57Z4Y3QTPRPXANCNFSM4I56B7FA .