Skip to content

Commit

Permalink
Make selection of subnet using docker more flexible. (#557)
Browse files Browse the repository at this point in the history
* Make selection of subnet using docker more flexible.

* Use Regex to find the IP address
  • Loading branch information
Boomatang authored Apr 22, 2024
1 parent c2b6f6a commit 11840b8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utils/docker-network-ipaddresspool.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ set -e

# Fallback to docker version of cmd
if [[ -z "$SUBNET" ]]; then
SUBNET=$(docker network inspect $networkName -f '{{ (index .IPAM.Config 0).Subnet }}')
SUBNET=$(docker network inspect $networkName --format '{{json .IPAM.Config}}' | ${YQ} '.[] | select( .Subnet | test("^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4}/\d+$")) | .Subnet')
fi
# Neither worked, error out
if [[ -z "$SUBNET" ]]; then
Expand Down

0 comments on commit 11840b8

Please sign in to comment.