mirror of
https://github.com/rclone/rclone.git
synced 2026-01-06 18:43:50 +00:00
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`.
This commit is contained in:
@@ -2,13 +2,13 @@
|
||||
|
||||
stop() {
|
||||
if status ; then
|
||||
docker stop $NAME
|
||||
docker stop "$NAME"
|
||||
echo "$NAME stopped"
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
if docker ps --format "{{.Names}}" | grep ^${NAME}$ >/dev/null ; then
|
||||
if docker ps --format '{{.Names}}' | grep -q "^${NAME}$" ; then
|
||||
echo "$NAME running"
|
||||
else
|
||||
echo "$NAME not running"
|
||||
@@ -18,5 +18,5 @@ status() {
|
||||
}
|
||||
|
||||
docker_ip() {
|
||||
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $NAME
|
||||
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{"\n"}}{{end}}' "$NAME" | head -1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user