deleting only OFN related Docker containers and images

This commit is contained in:
turinglabsorg
2021-02-11 14:30:07 +01:00
parent 3a3485614d
commit 07a42e8a21
2 changed files with 20 additions and 4 deletions

View File

@@ -11,10 +11,18 @@ docker network prune -f
echo '--------------------------------------'
echo 'Killing and removing all Docker images'
for i in $(docker images -a -q)
do
docker kill $i; wait;
docker rmi -f $i; wait;
echo "Evaluating $(docker image inspect --format='{{ .RepoTags }}' $i)"
if [[ $(docker image inspect --format='{{ .RepoTags }}' $i) =~ "openfoodnetwork" ]]
then
echo "Deleting $i"
docker kill $i; wait;
docker rmi -f $i; wait;
else
echo 'Ignoring container not related to OFN'
fi
done;
echo '------------'

View File

@@ -4,10 +4,18 @@
echo '------------------------------------------'
echo 'Killing and removing all Docker containers'
for i in $(docker ps -a -q)
do
docker kill $i; wait;
docker rm -f $i; wait;
echo "Evaluating $(docker inspect --format='{{ .Name }}' $i)"
if [[ $(docker inspect --format='{{ .Name }}' $i) =~ "openfoodnetwork" ]]
then
echo "Deleting OFN container: $i"
docker kill $i; wait;
docker rm -f $i; wait;
else
echo 'Ignoring container not related to OFN'
fi
done;
echo '------------'