Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

My solution on VPN Container + Sub-containers with container networking

Featured Replies

Hi all,

 

I'm not sure this is the right part of the forum to post, so mod, please move in case you find a more suitable place.

 

I just wanted to share my solution on the topic which I hope can help someone else!

 

My problem: 
I want to utilize a container with a VPN client as a docker network, to enable chosen containers to always be connected through the VPN connection. I tried all possible solutions found here and other places to make this work over time, but I always ended up having problems with having to manually restart these containers. I've tried the Rebuild-DNDC container on multiple occassions, but as it's primarily made to be use in combination with gluetun, and I unfortunately didn't get it to catch soft failures of containers properly.

 

Solution:
I put my (very) limited code production skills to use with the help of AI and created a bash script to be used with a cronjob with the User Scripts plugin. 
I wanted to share my now (for me) confirmed working solution as it's been running for two weeks straight without any hiccups. 

You can find the script here: https://github.com/sebstrgg/unraid-restart-vpn-containers

 

I'm open to any suggestions, feedbacks, pull requests etc. to make the script more user friendly and resilient. There might be obvious sub-optimizations as I don't have that much skill in coding overall and AI made a majority of the code with a lot of revisions through prompts from my part.

 

 

Edited by sebstrgg
typo

  • Community Expert

Interesting script.

Reviewing your code:
https://github.com/sebstrgg/unraid-restart-vpn-containers/blob/main/unraid-restart-vpn-containers.sh

I think this would have been better under https://forums.unraid.net/forum/47-docker-containers/
or https://forums.unraid.net/forum/58-docker-engine/

Other Thoughts: so? why not use a docker network create command to use the vpn interface?
or 
vpn setting allow ip address to the docker?

Edited by bmartino1

  • Author
On 4/30/2024 at 3:18 AM, bmartino1 said:

Interesting script.

Reviewing your code:
https://github.com/sebstrgg/unraid-restart-vpn-containers/blob/main/unraid-restart-vpn-containers.sh

I think this would have been better under https://forums.unraid.net/forum/47-docker-containers/
or https://forums.unraid.net/forum/58-docker-engine/

Other Thoughts: so? why not use a docker network create command to use the vpn interface?
or 
vpn setting allow ip address to the docker?

To be able to use a container as the network for other containers, you need to use the 'docker network create container:<container_name>' command as per other guides. No changes there.

The problem is that when the VPN container is restarted in some way (connection restarted or container) the containers connected to that network most often drops their connection overall. If the container is restarted it's due to the VPN container (master) changed container ID, leaving the connected containers hanging in wait of a restart. Here you can use the Rebuild-DNDC container to get help to restart the connected containers. 

The problem I've experienced is that the Rebuild-DNDC not always manages to properly restart the containers, or that when it's been a connection reset of any kind (leaving the master container intact with the same container ID), it fails to recognize this and the connected containers also drop their outbound connection (to the internet). 

I'm sure Rebuild-DNDC works properly if used with gluetun as it's built for that purpose - but since I don't, this is an annoying problem leaving me to manually restarting the containers.

Edited by sebstrgg
typo

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.