tprasadtp / protonvpn-docker

ProtonVPN Wireguard Docker Image. Supports ARMv8 (64-bit ) and x86 (64-Bit).
GNU General Public License v3.0
290 stars 25 forks source link

Can't connect container through protonvpn #13

Closed 2e6d7c49e26c closed 3 years ago

2e6d7c49e26c commented 3 years ago

I have .yml file the below. When I run it, everything works fine for protonvpn, but my ubuntuvpn image is not connected to protonvpn. From within ubuntu container i run: curl ipinfo.io. I get my host's public ip. Whereas from within protonvpn container i get the correct respond: user@user:~$ docker exec -ti e7c22a197065 bash root@e7c22a197065:/# curl ipinfo.io { "ip": "185.107.80.220", "city": "Amsterdam", "region": "North Holland", "country": "NL", "loc": "52.3740,4.8897", "org": "AS43350 NForce Entertainment B.V.", "postal": "1012", "timezone": "Europe/Amsterdam", "readme": "https://ipinfo.io/missingauth" }root@e7c22a197065:/#

My ubuntu-vpn.yml file is in folder docker. So network will be created as docker_default. version: '3' services: 1-protonvpn: image: ghcr.io/tprasadtp/protonvpn:2.2.6 container_name: 1-protonvpn environment:

I am new on linux and docker, therefore I am sorry for such bad questions. One more question: what should I add in my .yml file so my ubuntuvpn container couldn't connect to my host network when protonvpn container is down or disconnected or trying to reconnect? I appreciate your support and great work. Kind Regards, Good Luck!!! P.S. Here is below info from docker network

user@user:~$ docker network inspect docker_default [ { "Name": "docker_default", "Id": "7a257eab3229c45b320207133df8fea76eaef91580eabf0ee80934d5824dad03", "Created": "2021-01-25T15:18:23.341203282Z", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "172.19.0.0/16", "Gateway": "172.19.0.1" } ] }, "Internal": false, "Attachable": true, "Ingress": false, "ConfigFrom": { "Network": "" }, "ConfigOnly": false, "Containers": { "e6701deeabf1d772a96da12fd7acf593679b032e064940e0eeaf16d5e327f46a": { "Name": "1-ubuntuvpn", "EndpointID": "337c6d8cd1cb6058da995eeada02276bff960c032e1d7b868aac3047f17dc069", "MacAddress": "02:42:ac:13:00:03", "IPv4Address": "172.19.0.3/16", "IPv6Address": "" }, "e7c22a197065caa446dc7939be8f2fab34f1c2c54f086335e0c3c918a1422006": { "Name": "1-protonvpn", "EndpointID": "6c1d5632bd6bb6fb237cdeb508cf5109fd9d1077807df31416ec8cf9585ba1de", "MacAddress": "02:42:ac:13:00:02", "IPv4Address": "172.19.0.2/16", "IPv6Address": "" } }, "Options": {}, "Labels": { "com.docker.compose.network": "default", "com.docker.compose.project": "docker", "com.docker.compose.version": "1.25.0" } } ]

tprasadtp commented 3 years ago

You should use network_mode: service:<vpn-container-name>.

2e6d7c49e26c commented 3 years ago

Thank you very much. It worked. One more question: Is it possible to choose the server like NL-FREE#3, if yes, how?:

Or it always should be just - NL without FREE#3? When I added NL-FREE#3. I get response: [!] No Server in country NL-FREE#3 found [!] Please choose a valid country

tprasadtp commented 3 years ago

It's in the Readme. Use PROTONVPN_SERVER.

2e6d7c49e26c commented 3 years ago

I appreciate your support and please forgive me for such stupid questions disturbing you. How can I block ubuntu container to be connected to host when protonvpn is failed -Authentication failed or ProtonVPN server is failed when overloaded and/or connection is lost. So I don't want ubuntu container to have internet connection. I created 3 protonvpn containers and 3 ubuntu containers. the 3rd one protonvpn failed to connect due to(authentication failure) I guess limited devices, but my 3rd ubuntu container had connection to my host network. I don't want container to be connected at all if protonvpn has connection failure.
I appreciate your support. Thanks in advance.

tprasadtp commented 3 years ago
  1. As it says in docs, kill-switch is not reliable at the moment.
  2. docker alone cannot do what you want because it lacks ability to automatically restart unhealthy containers and has no concept of pods. What you are asking can be achieved in Kubernetes easily with healthchecks and init containers. Because docker lacks concept of a pod which share a network namespace it cannot be done with just docker in a reliable manner.

I will close this issue as original question has been answered. Open a new issue if you have other questions.