Jump to content

How to makr docker stop when ip changes


Go to solution Solved by JonathanM,

Recommended Posts

I have a static ip with my primary connection, I also have a backup connection that relies on lte and it's not unlimited. So I'm trying to figure out a way to stop some dockers when the primary connection is down, I think the easiest way is to write a script that checks the ip, so when it changes from the static one it shut down some dockers and when it's back up it restart those. I don't really know how to accomplish that

I'd really appreciate any help, thanks 

Link to comment
  • Solution

Here is a link to a post with some of the parts you need. I use it to start a VM after my gateway IP is pingable.

https://forums.unraid.net/topic/78454-boot-orderpriority-for-vms-and-dockers/?do=findComment&comment=727416

 

You could reuse some of the code to stop and start containers with the docker pause and unpause or stop and start.

 

It would need a major rewrite to accomplish exactly what you want cleanly, but I think all the parts are there.

Link to comment

Than you! I made 2 scripts, one that starts with array and stay in loop until my static ip can't be reached, so it stops some dockers, restart a vm and start the second script, that stays up until my static ip is up than it make the same thing but in reverse. Seems to work just fine

  • Like 1
Link to comment

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...