avoid to find a stopped instance
This commit is contained in:
parent
5f8841f2ac
commit
aa020f4462
@ -44,7 +44,9 @@ function ufw-docker--allow() {
|
|||||||
docker inspect "$INSTANCE_NAME" &>/dev/null ||
|
docker inspect "$INSTANCE_NAME" &>/dev/null ||
|
||||||
die "Docker instance \"$INSTANCE_NAME\" doesn't exist."
|
die "Docker instance \"$INSTANCE_NAME\" doesn't exist."
|
||||||
|
|
||||||
mapfile -t INSTANCE_IP_ADDRESSES < <(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{"\n"}}{{end}}' "$INSTANCE_NAME" | remove_blank_lines)
|
mapfile -t INSTANCE_IP_ADDRESSES < <(docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{"\n"}}{{end}}' "$INSTANCE_NAME" 2>/dev/null | remove_blank_lines)
|
||||||
|
|
||||||
|
[[ -z "${INSTANCE_IP_ADDRESSES:-}" ]] && die "Could not find a running instance \"$INSTANCE_NAME\"."
|
||||||
|
|
||||||
mapfile -t PORT_PROTO_LIST < <(docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}}{{with $conf}}{{$p}}{{"\n"}}{{end}}{{end}}' "$INSTANCE_NAME" | remove_blank_lines)
|
mapfile -t PORT_PROTO_LIST < <(docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}}{{with $conf}}{{$p}}{{"\n"}}{{end}}{{end}}' "$INSTANCE_NAME" | remove_blank_lines)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user