mirror of
https://github.com/chaifeng/ufw-docker.git
synced 2025-05-10 21:48:30 +02:00
watching docker events
This commit is contained in:
parent
bd991a0367
commit
5f8841f2ac
1 changed files with 10 additions and 0 deletions
|
@ -13,6 +13,16 @@ case "$1" in
|
||||||
name="${label#ufw.public.}"
|
name="${label#ufw.public.}"
|
||||||
echo "${name}=$port"
|
echo "${name}=$port"
|
||||||
done
|
done
|
||||||
|
docker events --format '{{.Time}} {{.Status}} {{.Actor.Attributes.name}}' --filter 'scope=local' --filter 'type=container' |
|
||||||
|
while read time status name; do
|
||||||
|
echo "$time $status $name" >&2
|
||||||
|
|
||||||
|
declare -a agent_opts=(run --rm --cap-add NET_ADMIN --network host -v /etc/ufw:/etc/ufw "${ufw_docker_agent_image}")
|
||||||
|
[[ "status" = start ]] && agent_opts+=(allow "$name")
|
||||||
|
[[ "status" = stop ]] && agent_opts+=(delete allow "$name")
|
||||||
|
|
||||||
|
echo docker "${agent_opts[@]}"
|
||||||
|
done
|
||||||
sleep 60; exit 1
|
sleep 60; exit 1
|
||||||
;;
|
;;
|
||||||
delete|allow)
|
delete|allow)
|
||||||
|
|
Loading…
Add table
Reference in a new issue