Skip to content

Instantly share code, notes, and snippets.

@misraX
Last active June 17, 2017 18:21
Show Gist options
  • Save misraX/c3439a29767304298cade52f32648d93 to your computer and use it in GitHub Desktop.
Save misraX/c3439a29767304298cade52f32648d93 to your computer and use it in GitHub Desktop.
#!/bin/sh
#####
#mmm, misraX
##### Automatically stop all docker containers ##########
# Loop over containeres, awk the first col "CONTAINER"
# exclude the string that start with ! /CONT/ to exclude CONTAINER ID
# as it's an invalid container ID.
for i in $(docker ps | awk '! /CONT/ {print $1}')
do
# Stop containers by ID
docker stop "$i" && echo "docker stopped" "$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment