mirror of
https://github.com/chaifeng/ufw-docker.git
synced 2025-05-10 13:38:32 +02:00
check published port of a service
This commit is contained in:
parent
a91e864cfe
commit
2c5391dcec
1 changed files with 13 additions and 0 deletions
13
ufw-docker
13
ufw-docker
|
@ -130,6 +130,19 @@ function ufw-docker--service-allow() {
|
|||
return 1
|
||||
fi
|
||||
|
||||
declare port="${service_port%/*}"
|
||||
declare proto="(tcp|udp)"
|
||||
[[ "$service_port" = */* ]] && proto="${service_port#*/}"
|
||||
|
||||
if ! docker service inspect "$service_name" \
|
||||
--format '{{range .Endpoint.Spec.Ports}}{{.TargetPort}}/{{.Protocol}}{{end}}' |
|
||||
grep -E "^${port}/${proto}\$"; then
|
||||
die "Service $service_name does not publish port $service_port."
|
||||
return 1
|
||||
fi
|
||||
|
||||
service_label="ufw.public.${service_name}=${service_port}"
|
||||
|
||||
}
|
||||
|
||||
function ufw-docker--install() {
|
||||
|
|
Loading…
Add table
Reference in a new issue