commit d492aa2d3c57310f104f8802c842347bcd589bc9 parent 1875655fe18a517978d5931d5d3dc75fabb2eeae Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Tue, 4 Dec 2018 08:14:22 +0100 Determine appropriate docker command based on uname Diffstat:
M | links/bin/docker-delete-all | | | 8 | ++++++-- |
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/links/bin/docker-delete-all b/links/bin/docker-delete-all @@ -1,5 +1,9 @@ #!/bin/bash + +[ "$(uname)" = "Linux" ] && dockercmd="sudo docker" || dockercmd=docker + # Delete all containers -docker rm $(docker ps -a -q) +$dockercmd rm $($dockercmd ps -a -q) + # Delete all images -docker rmi $(docker images -q) +$dockercmd rmi $($dockercmd images -q)