When running Docker For Windows on a VPN, company Network, or from home, it was necessary to frequently switch between IP addresses. This caused Docker to take long start-ups by attempting to use the previous IP. I didn't particularly like this aspect about Docker, so I wrote this script that will allow one to dynamically update the IP address associated with their Docker instance either when they login to their device or when they choose to update the IP address by running the script using the convenient shortcut.
-
Ensure CNTLM is working on your computer (if behind proxy)
-
Ensure you have docker for windows installed on your device
- Pre-requisites:
- Windows 10
- 64-bit device
- Pre-requisites:
-
Extract the contents of this repository to
<c:\Program Files\Docker>
or wherever you have Docker installed:- Add the 'VPN IP Sync Docker - (shortcut)' to your desktop
- this shortcut will trigger an IP sync manually by calling the dockerIpSync.ps1 powershell script through a
<.bat>
. You may need to update the<.ps1>
with the path to your Docker Directory if it is different from the default. - Use this shortcut whenever you connect to a new network and/or need to refresh your IP address
- this shortcut will trigger an IP sync manually by calling the dockerIpSync.ps1 powershell script through a
- Add the 'VPN IP Sync Docker - (shortcut)' to your desktop
-
Run the following script in powershell (administrator) to schedule a logon task that will automatically sync your IP to Docker when you login to your device:
- run the script below in powershell:
<$trigger = New-JobTrigger -AtLogOn -RandomDelay 00:01:30>
<Register-ScheduledJob -Trigger $trigger -FilePath 'C:\path\to\Docker\dockerIpSync.ps1' -Name dockerIpSync>
- If the task doesn't execute (and it might not for a variety of reasons), then run the VPN Sync Manually using the shortcut. You can also check if the job ran by running:
<Get-Job -Name dockerIpSync>
in your powershell window
- run the script below in powershell:
-
Quit and reopen Docker if it was open when you synced IP addresses
Feel free to reach out to me on GitHub, submit a bug, or pull request.