Kill process instead of container, on container restart.
When Docker restarts a container and something goes wrong attaching the network, kill the process inside the container instead of killing the container, so that Docker will restart it again
This commit is contained in:
1 parent
01e3d1d81b
commit
8d71467802
2 files changed
+32
-4
No files matched your search
@@ -832,6 +832,10 @@ kill_container() {
|
||||
docker kill $1 >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
kill_container_process() {
|
||||
kill -9 $(docker inspect --format='{{.State.Pid}}' $1) >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
with_container_netns_or_die() {
|
||||
if ! with_container_netns "$@" >/dev/null ; then
|
||||
kill_container $1
|
||||
@@ -839,6 +843,13 @@ with_container_netns_or_die() {
|
||||
fi
|
||||
}
|
||||
|
||||
with_container_netns_or_kill() {
|
||||
if ! with_container_netns "$@" >/dev/null ; then
|
||||
kill_container_process $1
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Execute arguments as a command within the $CONTAINER_NETNS network namespace
|
||||
netnsenter() {
|
||||
nsenter --net=$CONTAINER_NETNS "$@"
|
||||
@@ -1460,6 +1471,13 @@ ipam_cidrs_or_die() {
|
||||
fi
|
||||
}
|
||||
|
||||
ipam_cidrs_or_kill() {
|
||||
if ! ipam_cidrs "$@" ; then
|
||||
kill_container_process $2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
show_addrs() {
|
||||
addrs=
|
||||
for cidr in "$@" ; do
|
||||
@@ -2136,6 +2154,9 @@ EOF
|
||||
--or-die)
|
||||
ATTACH_TYPE="_or_die"
|
||||
;;
|
||||
--or-kill)
|
||||
ATTACH_TYPE="_or_kill"
|
||||
;;
|
||||
--rewrite-hosts)
|
||||
REWRITE_HOSTS=1
|
||||
;;
|
||||
|
||||
Reference in new issue
Block a user