Don't check if container is running when we only want its ID.
This avoids trying to decide if "restarting" is as good as "running". In wait_for_status we now explitly check_running, and in dns_add/remove we add an extra check_running test.
This commit is contained in:
1 parent
30fef10afa
commit
a750ef8033
1 file changed
+5
-13
@@ -951,23 +951,14 @@ stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Given a container name or short ID in $1, ensure the specified
|
# Given a container name or short ID in $1, ensure the specified
|
||||||
# container is running and then print its full ID to stdout. If
|
# container exists and then print its full ID to stdout. If
|
||||||
# it's not running or doesn't exist, print an error to stderr and
|
# it doesn't exist, print an error to stderr and
|
||||||
# return with an indicative non-zero exit code.
|
# return with an indicative non-zero exit code.
|
||||||
container_id() {
|
container_id() {
|
||||||
if ! status=$(docker inspect --format='{{.State.Running}} {{.Id}}' $1 2>/dev/null) ; then
|
if ! docker inspect --format='{{.Id}}' $1 2>/dev/null ; then
|
||||||
echo "Error: No such container: $1" >&2
|
echo "Error: No such container: $1" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
case "$status" in
|
|
||||||
true*)
|
|
||||||
echo "${status#true }"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "$1 container is not running." >&2
|
|
||||||
return 2
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
container_ip() {
|
container_ip() {
|
||||||
@@ -1033,7 +1024,7 @@ wait_for_status() {
|
|||||||
shift
|
shift
|
||||||
while true ; do
|
while true ; do
|
||||||
"$@" GET /status >/dev/null 2>&1 && return 0
|
"$@" GET /status >/dev/null 2>&1 && return 0
|
||||||
if ! container_id $container >/dev/null 2>&1 ; then
|
if ! check_running $container >/dev/null 2>&1 ; then
|
||||||
echo $(death_msg $container) >&2
|
echo $(death_msg $container) >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@@ -1286,6 +1277,7 @@ collect_dns_add_remove_args() {
|
|||||||
[ $# -eq 0 -a \( -n "$C" -o \( $IP_COUNT -gt 0 -a -n "$FQDN" \) \) ] || usage
|
[ $# -eq 0 -a \( -n "$C" -o \( $IP_COUNT -gt 0 -a -n "$FQDN" \) \) ] || usage
|
||||||
check_running $CONTAINER_NAME
|
check_running $CONTAINER_NAME
|
||||||
if [ -n "$C" ] ; then
|
if [ -n "$C" ] ; then
|
||||||
|
check_running $C
|
||||||
CONTAINER=$(container_id $C)
|
CONTAINER=$(container_id $C)
|
||||||
[ $IP_COUNT -gt 0 ] || IP_ARGS=$(with_container_addresses echo_ips $CONTAINER)
|
[ $IP_COUNT -gt 0 ] || IP_ARGS=$(with_container_addresses echo_ips $CONTAINER)
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in new issue
Block a user