Dynamically choose the Docker network subnet
This commit is contained in:
parent
ff4f2ae0b6
commit
5c2ab9fc9e
|
@ -158,6 +158,24 @@ if [ ! -z "${MAILCOW_BRANCH}" ]; then
|
|||
git_branch=${MAILCOW_BRANCH}
|
||||
fi
|
||||
|
||||
if [[ $(docker network ls -q \
|
||||
| xargs docker network inspect --format $'{{range .IPAM.Config}}{{.Subnet}}\n{{end}}' \
|
||||
| grep -qsP '172\.22.*' )$? \
|
||||
-eq 0 ]]; then
|
||||
|
||||
max_octet=$(docker network ls -q \
|
||||
| xargs -I {} docker network inspect {} --format $'{{range .IPAM.Config}}{{.Subnet}}\n{{end}}' \
|
||||
| grep -P '172\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$' \
|
||||
| sort \
|
||||
| tail -n 1 \
|
||||
| sed -e 's~\(172\)\.\([0-9]\+\).*~\2~g')
|
||||
|
||||
DOCKER_NETWORK="172.$(($max_octet+1)).1"
|
||||
else
|
||||
DOCKER_NETWORK='172.22.1'
|
||||
fi
|
||||
|
||||
|
||||
git fetch --all
|
||||
git checkout -f $git_branch
|
||||
|
||||
|
@ -361,7 +379,7 @@ LOG_LINES=9999
|
|||
# Internal IPv4 /24 subnet, format n.n.n (expands to n.n.n.0/24)
|
||||
# Use private IPv4 addresses only, see https://en.wikipedia.org/wiki/Private_network#Private_IPv4_addresses
|
||||
|
||||
IPV4_NETWORK=172.22.1
|
||||
IPV4_NETWORK=${DOCKER_NETWORK}
|
||||
|
||||
# Internal IPv6 subnet in fc00::/7
|
||||
# Use private IPv6 addresses only, see https://en.wikipedia.org/wiki/Private_network#Private_IPv6_addresses
|
||||
|
|
Loading…
Reference in New Issue