rclone/fstest/testserver/init.d/docker.bash
Ivan Andreev 5834020316
docker.bash: work correctly with multi-ip containers (#5028)
Currently if container under test has multiple IP addresses,
the `docker_ip` function from `docker.sh` will return a gibberish.
This patch makes it return the first address found.
Additionally, I apply shellcheck on `docker.sh`.
2021-02-17 03:38:02 +03:00

22 lines
423 B
Bash

#!/bin/bash
stop() {
if status ; then
docker stop "$NAME"
echo "$NAME stopped"
fi
}
status() {
if docker ps --format '{{.Names}}' | grep -q "^${NAME}$" ; then
echo "$NAME running"
else
echo "$NAME not running"
return 1
fi
return 0
}
docker_ip() {
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{"\n"}}{{end}}' "$NAME" | head -1
}