Compare commits
2 Commits
c04b6d43e5
...
287c13a311
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
287c13a311 | ||
|
|
14e6d4aba1 |
@ -2,10 +2,29 @@
|
|||||||
|
|
||||||
installDockerNetwork()
|
installDockerNetwork()
|
||||||
{
|
{
|
||||||
# Check if network setup is needed
|
if [[ "$DOCKER_NETWORK_SETUP_NEEDED" != "true" ]]; then
|
||||||
if [[ "$DOCKER_NETWORK_SETUP_NEEDED" == "true" ]]; then
|
isNotice "Docker network $CFG_NETWORK_NAME already exists or setup not needed"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
isHeader "Create a Docker Network"
|
isHeader "Create a Docker Network"
|
||||||
|
|
||||||
|
# Re-check existence right before creating, and converge instead of erroring
|
||||||
|
# if it's already there. The requirement check that set
|
||||||
|
# DOCKER_NETWORK_SETUP_NEEDED can run before the rootless daemon socket is
|
||||||
|
# reachable (a failed inspect is indistinguishable from "network absent"), and
|
||||||
|
# a previous install leaves the network behind — both make us think it's new
|
||||||
|
# when it isn't. If it exists, leave it in place and adopt its real subnet so
|
||||||
|
# CFG stays in step with docker (and we don't randomize to a subnet we can't apply).
|
||||||
|
if dockerCommandRun "docker network inspect $CFG_NETWORK_NAME > /dev/null 2>&1"; then
|
||||||
|
local current_subnet; current_subnet=$(dockerCommandRun "docker network inspect $CFG_NETWORK_NAME --format '{{range .IPAM.Config}}{{.Subnet}}{{end}}' 2>/dev/null")
|
||||||
|
isNotice "Docker network $CFG_NETWORK_NAME already exists, leaving it in place"
|
||||||
|
if [[ -n "$current_subnet" && "$current_subnet" != "$CFG_NETWORK_SUBNET" ]]; then
|
||||||
|
adoptDockerSubnet "$current_subnet"
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
isNotice "Network $CFG_NETWORK_NAME not found, creating now"
|
isNotice "Network $CFG_NETWORK_NAME not found, creating now"
|
||||||
|
|
||||||
# Check if we need to generate a new subnet
|
# Check if we need to generate a new subnet
|
||||||
@ -28,7 +47,4 @@ $CFG_NETWORK_NAME"
|
|||||||
isError "Failed to create Docker network $CFG_NETWORK_NAME"
|
isError "Failed to create Docker network $CFG_NETWORK_NAME"
|
||||||
isError " $result"
|
isError " $result"
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
isNotice "Docker network $CFG_NETWORK_NAME already exists or setup not needed"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user