Docker + Compose IP discovery, conflict checks, and free IP allocation for self-hosted environments.
- Discovers IP usage from Docker runtime and Compose files
- Optional
ps --portsview for published and exposed container ports - Detects duplicate/static-IP conflicts
- Finds next-free addresses from configured IP groups / ranges
- Falls back to compose-only mode when Docker is unavailable
- JSON output (
--json)
curl -fsSL https://raw.githubusercontent.com/Puhi8/dockernet/main/installbin.sh | bashRequires: Go 1.24+
go install github.com/Puhi8/dockernet@latest
# Ensure Go exists
export PATH="$PATH:$(go env GOPATH)/bin"
# Copy create default config
curl -fsSL https://raw.githubusercontent.com/Puhi8/dockernet/main/dockernet.conf.example -o ~/.dockernet.confRequires: Go 1.24+ (for building from source)
# Build binary
go build -o dockernet .
# Create config
cp dockernet.conf.example ~/.dockernet.confdevelopment tags: perftrace, debug
for static/minimized build:
CGO_ENABLED=0 go build -ldflags="-s -w" -o dockernet .# List running entries in bridge network
dockernet ps --running --network bridge
# Include published/exposed ports in ps output
dockernet ps --ports
# Optional: include protocol in ports output
dockernet ps --ports --ports-protocol
# Check conflicts only in one network
dockernet check --network bridge
# Get next 3 free IPs for all groups
dockernet nextFree 3
# Get exactly 1 free IP
dockernet nextFree 1
# Get free IPs by group index (0-based config order)
dockernet nextFree --group-number 1 2
# Validate group overlaps/ranges
dockernet sections --validateDefault config path:
$DOCKERNET_CONFIGif set- otherwise
~/.dockernet.conf
Example config (in dockernet.conf.example):
NETWORKS="bridge,host"
COMPOSE_ROOTS="/var/composeFiles,/home/username/projects"
IGNORE_PATHS="node_modules,.git,volumes,data"
ENABLE_IPV6="false"
ENABLE_COLOR="true"
GROUP_INFRA="172.18.1.1-172.18.1.254"
GROUP_APPS="172.18.2.1-172.18.2.254"Config keys:
NETWORKScomma-separated network scope (host is list-only)COMPOSE_ROOTScomma-separated compose scan rootsIGNORE_PATHSpath ignored during compose discoveryENABLE_IPV6enable IPv6 discovery and checksENABLE_COLORenable colorized terminal outputGROUP_<NAME>allocation/check range in full form (a.b.c.d-a.b.c.d)
Config values can be overridden with environment variables:
DOCKERNET_CONFIGDOCKERNET_ROOTSDOCKERNET_IPV6DOCKERNET_COLORDOCKERNET_JSONDOCKERNET_QUIET
Output modes:
- Plain text (default)
- JSON (
--json)
Exit codes:
0success1runtime/config error2conflicts found (check)3degraded compose-only mode (Docker unavailable)